WingMan – Blame information for rev 14
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | |||
14 | office | 5 | namespace WingMan.Bindings |
4 | office | 6 | { |
10 | office | 7 | public class KeyBinding : IEquatable<KeyBinding> |
4 | office | 8 | { |
10 | office | 9 | public KeyBinding() |
5 | office | 10 | { |
7 | office | 11 | } |
5 | office | 12 | |
10 | office | 13 | public KeyBinding(string name, List<string> keys) : this() |
5 | office | 14 | { |
15 | Name = name; |
||
16 | Keys = keys; |
||
17 | } |
||
18 | |||
4 | office | 19 | public string DisplayName => $"{Name} ({string.Join(" + ", Keys.ToArray())})"; |
20 | |||
21 | public string Name { get; set; } = string.Empty; |
||
22 | |||
23 | public List<string> Keys { get; set; } = new List<string>(); |
||
7 | office | 24 | |
10 | office | 25 | public bool Equals(KeyBinding other) |
7 | office | 26 | { |
27 | if (ReferenceEquals(null, other)) return false; |
||
28 | if (ReferenceEquals(this, other)) return true; |
||
29 | return string.Equals(Name, other.Name) && Keys.SequenceEqual(other.Keys); |
||
30 | } |
||
31 | |||
32 | public override bool Equals(object obj) |
||
33 | { |
||
34 | if (ReferenceEquals(null, obj)) return false; |
||
35 | if (ReferenceEquals(this, obj)) return true; |
||
36 | if (obj.GetType() != GetType()) return false; |
||
10 | office | 37 | return Equals((KeyBinding) obj); |
7 | office | 38 | } |
39 | |||
40 | public override int GetHashCode() |
||
41 | { |
||
42 | unchecked |
||
43 | { |
||
44 | return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Keys != null ? Keys.GetHashCode() : 0); |
||
45 | } |
||
46 | } |
||
4 | office | 47 | } |
48 | } |