Skip to content

Commit a0c70a3

Browse files
Inherit
1 parent 99d1807 commit a0c70a3

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
2+
using System.Text.Json.Serialization;
63

74
namespace Flow.Launcher.Infrastructure.UserSettings
85
{
9-
public class CustomShortcutModel
6+
public class CustomShortcutBaseModel
107
{
118
public string Key { get; set; }
12-
public string Value { get; set; }
139

14-
public CustomShortcutModel(string key, string value)
15-
{
16-
Key = key;
17-
Value = value;
18-
}
10+
[JsonIgnore]
11+
public Func<string> Expand { get; set; } = () => { return ""; };
1912

2013
public override bool Equals(object obj)
2114
{
22-
return obj is CustomShortcutModel other &&
23-
Key == other.Key &&
24-
Value == other.Value;
15+
return obj is CustomShortcutBaseModel other &&
16+
Key == other.Key;
2517
}
2618

2719
public override int GetHashCode()
2820
{
29-
return HashCode.Combine(Key, Value);
21+
return HashCode.Combine(Key);
22+
}
23+
};
24+
25+
public class CustomShortcutModel : CustomShortcutBaseModel
26+
{
27+
public string Value
28+
{
29+
get { return Expand(); }
30+
set { Expand = () => { return value; }; }
31+
}
32+
33+
public CustomShortcutModel(string key, string value)
34+
{
35+
Key = key;
36+
Value = value;
3037
}
3138

3239
public void Deconstruct(out string key, out string value)
3340
{
3441
key = Key;
35-
value = Value;
42+
value = Expand();
3643
}
3744

3845
public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut)

0 commit comments

Comments
 (0)