11using System ;
22using System . Text . Json . Serialization ;
3+ using System . Threading . Tasks ;
34
45namespace Flow . Launcher . Infrastructure . UserSettings
56{
7+ #region Base
8+
69 public abstract class ShortcutBaseModel
710 {
811 public string Key { get ; set ; }
912
10- [ JsonIgnore ]
11- public Func < string > Expand { get ; set ; } = ( ) => { return "" ; } ;
12-
1313 public override bool Equals ( object obj )
1414 {
1515 return obj is ShortcutBaseModel other &&
@@ -22,16 +22,14 @@ public override int GetHashCode()
2222 }
2323 }
2424
25- public class CustomShortcutModel : ShortcutBaseModel
25+ public class BaseCustomShortcutModel : ShortcutBaseModel
2626 {
2727 public string Value { get ; set ; }
2828
29- [ JsonConstructorAttribute ]
30- public CustomShortcutModel ( string key , string value )
29+ public BaseCustomShortcutModel ( string key , string value )
3130 {
3231 Key = key ;
3332 Value = value ;
34- Expand = ( ) => { return Value ; } ;
3533 }
3634
3735 public void Deconstruct ( out string key , out string value )
@@ -40,26 +38,69 @@ public void Deconstruct(out string key, out string value)
4038 value = Value ;
4139 }
4240
43- public static implicit operator ( string Key , string Value ) ( CustomShortcutModel shortcut )
41+ public static implicit operator ( string Key , string Value ) ( BaseCustomShortcutModel shortcut )
4442 {
4543 return ( shortcut . Key , shortcut . Value ) ;
4644 }
4745
48- public static implicit operator CustomShortcutModel ( ( string Key , string Value ) shortcut )
46+ public static implicit operator BaseCustomShortcutModel ( ( string Key , string Value ) shortcut )
4947 {
50- return new CustomShortcutModel ( shortcut . Key , shortcut . Value ) ;
48+ return new BaseCustomShortcutModel ( shortcut . Key , shortcut . Value ) ;
5149 }
5250 }
5351
54- public class BuiltinShortcutModel : ShortcutBaseModel
52+ public class BaseBuiltinShortcutModel : ShortcutBaseModel
5553 {
5654 public string Description { get ; set ; }
5755
58- public BuiltinShortcutModel ( string key , string description , Func < string > expand )
56+ public BaseBuiltinShortcutModel ( string key , string description )
5957 {
6058 Key = key ;
6159 Description = description ;
62- Expand = expand ?? ( ( ) => { return "" ; } ) ;
6360 }
6461 }
62+
63+ #endregion
64+
65+ #region Custom Shortcut
66+
67+ public class CustomShortcutModel : BaseCustomShortcutModel
68+ {
69+ [ JsonIgnore ]
70+ public Func < string > Expand { get ; set ; } = ( ) => { return string . Empty ; } ;
71+
72+ [ JsonConstructor ]
73+ public CustomShortcutModel ( string key , string value ) : base ( key , value )
74+ {
75+ Expand = ( ) => { return Value ; } ;
76+ }
77+ }
78+
79+ #endregion
80+
81+ #region Buildin Shortcut
82+
83+ public class BuiltinShortcutModel : BaseBuiltinShortcutModel
84+ {
85+ [ JsonIgnore ]
86+ public Func < string > Expand { get ; set ; } = ( ) => { return string . Empty ; } ;
87+
88+ public BuiltinShortcutModel ( string key , string description , Func < string > expand ) : base ( key , description )
89+ {
90+ Expand = expand ?? ( ( ) => { return string . Empty ; } ) ;
91+ }
92+ }
93+
94+ public class AsyncBuiltinShortcutModel : BaseBuiltinShortcutModel
95+ {
96+ [ JsonIgnore ]
97+ public Func < Task < string > > ExpandAsync { get ; set ; } = ( ) => { return Task . FromResult ( string . Empty ) ; } ;
98+
99+ public AsyncBuiltinShortcutModel ( string key , string description , Func < Task < string > > expandAsync ) : base ( key , description )
100+ {
101+ ExpandAsync = expandAsync ?? ( ( ) => { return Task . FromResult ( string . Empty ) ; } ) ;
102+ }
103+ }
104+
105+ #endregion
65106}
0 commit comments