| | 1 | | using JetBrains.Annotations; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | |
|
| | 5 | | namespace DCL.MyAccount |
| | 6 | | { |
| | 7 | | public class AdditionalInfoOptionsModel |
| | 8 | | { |
| | 9 | | public enum InputType |
| | 10 | | { |
| | 11 | | FreeFormText, |
| | 12 | | StrictValueList, |
| | 13 | | Date |
| | 14 | | } |
| | 15 | |
|
| | 16 | |
|
| | 17 | | public class Option |
| | 18 | | { |
| | 19 | | public Action<string> OnValueSubmitted; |
| | 20 | | public Action OnRemoved; |
| | 21 | |
|
| 363 | 22 | | public bool IsAvailable { get; set; } |
| 352 | 23 | | public string Name { get; set; } |
| 352 | 24 | | public InputType InputType { get; set; } |
| 224 | 25 | | [CanBeNull] public string[] Values { get; set; } |
| 32 | 26 | | [CanBeNull] public string DateFormat { get; set; } |
| | 27 | |
|
| | 28 | | protected bool Equals(Option other) => |
| 0 | 29 | | IsAvailable == other.IsAvailable && Name == other.Name && InputType == other.InputType && Equals(Values, |
| | 30 | |
|
| | 31 | | public override bool Equals(object obj) |
| | 32 | | { |
| 0 | 33 | | if (ReferenceEquals(null, obj)) return false; |
| 0 | 34 | | if (ReferenceEquals(this, obj)) return true; |
| 0 | 35 | | if (obj.GetType() != this.GetType()) return false; |
| 0 | 36 | | return Equals((Option)obj); |
| | 37 | | } |
| | 38 | |
|
| | 39 | | public override int GetHashCode() => |
| 0 | 40 | | HashCode.Combine(IsAvailable, Name, (int)InputType, Values, DateFormat); |
| | 41 | | } |
| | 42 | |
|
| 87 | 43 | | public Dictionary<string, Option> Options { get; set; } |
| | 44 | |
|
| | 45 | | protected bool Equals(AdditionalInfoOptionsModel other) |
| | 46 | | { |
| 0 | 47 | | if (Options.Count != other.Options.Count) |
| 0 | 48 | | return false; |
| | 49 | |
|
| 0 | 50 | | foreach (string key in Options.Keys) |
| | 51 | | { |
| 0 | 52 | | if (!other.Options.ContainsKey(key)) |
| 0 | 53 | | return false; |
| | 54 | |
|
| 0 | 55 | | if (!Options[key].Equals(other.Options[key])) |
| 0 | 56 | | return false; |
| | 57 | | } |
| | 58 | |
|
| 0 | 59 | | return true; |
| 0 | 60 | | } |
| | 61 | |
|
| | 62 | | public override bool Equals(object obj) |
| | 63 | | { |
| 0 | 64 | | if (ReferenceEquals(null, obj)) return false; |
| 0 | 65 | | if (ReferenceEquals(this, obj)) return true; |
| 0 | 66 | | if (obj.GetType() != this.GetType()) return false; |
| 0 | 67 | | return Equals((AdditionalInfoOptionsModel)obj); |
| | 68 | | } |
| | 69 | |
|
| | 70 | | public override int GetHashCode() => |
| 0 | 71 | | (Options != null ? Options.GetHashCode() : 0); |
| | 72 | | } |
| | 73 | | } |