mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Flow.Launcher.Infrastructure.UserSettings
|
|
{
|
|
public class CustomShortcutBaseModel
|
|
{
|
|
public string Key { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public Func<string> Expand { get; set; } = () => { return ""; };
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
return obj is CustomShortcutBaseModel other &&
|
|
Key == other.Key;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Key);
|
|
}
|
|
};
|
|
|
|
public class CustomShortcutModel : CustomShortcutBaseModel
|
|
{
|
|
public string Value
|
|
{
|
|
get { return Expand(); }
|
|
set { Expand = () => { return value; }; }
|
|
}
|
|
|
|
public CustomShortcutModel(string key, string value)
|
|
{
|
|
Key = key;
|
|
Value = value;
|
|
}
|
|
|
|
public void Deconstruct(out string key, out string value)
|
|
{
|
|
key = Key;
|
|
value = Expand();
|
|
}
|
|
|
|
public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut)
|
|
{
|
|
return (shortcut.Key, shortcut.Value);
|
|
}
|
|
|
|
public static implicit operator CustomShortcutModel((string Key, string Value) shortcut)
|
|
{
|
|
return new CustomShortcutModel(shortcut.Key, shortcut.Value);
|
|
}
|
|
}
|
|
}
|