Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
CompetitionDistanceRule.cs
1using CommunityToolkit.Mvvm.ComponentModel;
4
6{
10 public partial class CompetitionDistanceRule : ObservableObject, IEquatable<CompetitionDistanceRule>, ICloneable
11 {
12 #region Constructors
13
18 {
19 }
20
26 {
27 if (other == null) { return; }
28 this.MinAge = other.MinAge;
29 this.MaxAge = other.MaxAge;
30 this.SwimmingStyle = other.SwimmingStyle;
31 this.Distance = other.Distance;
32 }
33
34 #endregion
35
36 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37
38 #region Properties
39
40 private byte _minAge;
44 [FileServiceOrder]
45 public byte MinAge
46 {
47 get => _minAge;
48 set => SetProperty(ref _minAge, value);
49 }
50
51 private byte _maxAge;
55 [FileServiceOrder]
56 public byte MaxAge
57 {
58 get => _maxAge;
59 set => SetProperty(ref _maxAge, value);
60 }
61
62 private SwimmingStyles _swimmingStyle;
66 [FileServiceOrder]
68 {
69 get => _swimmingStyle;
70 set => SetProperty(ref _swimmingStyle, value);
71 }
72
73 private ushort _distance;
77 [FileServiceOrder]
78 public ushort Distance
79 {
80 get => _distance;
81 set => SetProperty(ref _distance, value);
82 }
83
84 #endregion
85
86 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87
88 #region SetPropertyFromString helper
89
96 public static void SetPropertyFromString(CompetitionDistanceRule dataObj, string propertyName, string value)
97 {
98 switch (propertyName)
99 {
100 case nameof(MinAge): dataObj.MinAge = byte.Parse(value); break;
101 case nameof(MaxAge): dataObj.MaxAge = byte.Parse(value); break;
102 case nameof(SwimmingStyle):
103 if (EnumCoreLocalizedStringHelper.TryParse(value, out SwimmingStyles parsedStyle))
104 {
105 dataObj.SwimmingStyle = parsedStyle;
106 }
107 break;
108 case nameof(Distance): dataObj.Distance = ushort.Parse(value); break;
109 default: break;
110 }
111 }
112
113 #endregion
114
115 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
116
117 #region Equality, HashCode, ToString, Clone
118
124 public override bool Equals(object obj)
125 => obj is CompetitionDistanceRule c && (c.MinAge, c.MaxAge, c.SwimmingStyle, c.Distance).Equals((MinAge, MaxAge, SwimmingStyle, Distance));
126
133 => Equals((object)other);
134
141 public override int GetHashCode()
142 => base.GetHashCode();
143 //=> (MinAge, MaxAge, SwimmingStyle, Distance).GetHashCode();
144
149 public override string ToString()
150 => $"MinAge: {MinAge}, MaxAge: {MaxAge}, SwimmingStyle: {SwimmingStyle} --> Distance: {Distance}m";
151
156 public object Clone()
157 => new CompetitionDistanceRule(this);
158
159 #endregion
160
161 }
162}
override int GetHashCode()
Serves as the default hash function.
CompetitionDistanceRule(CompetitionDistanceRule other)
Clone constructor for a object.
bool Equals(CompetitionDistanceRule other)
Indicates wheather the current object is equal to another object of the same type.
static void SetPropertyFromString(CompetitionDistanceRule dataObj, string propertyName, string value)
Set the requested property in the CompetitionDistanceRule object by parsing the given string value.
SwimmingStyles SwimmingStyle
SwimmingStyles for this rule.
object Clone()
Create a new object that has the same property values than this one.
override string ToString()
Returns a string that represents the current object.
override bool Equals(object obj)
Compare if two are equal.
SwimmingStyles
Available swimming styles.