1using CommunityToolkit.Mvvm.ComponentModel;
10 public partial class Competition : ObservableObject, IEquatable<Competition>, ICloneable
27 if (other ==
null) {
return; }
29 this.Gender = other.
Gender;
43 #region Basic properties
53 set => SetProperty(ref _id, value);
64 set => SetProperty(ref _gender, value);
74 get => _swimmingStyle;
75 set => SetProperty(ref _swimmingStyle, value);
78 private byte _age = 0;
86 set => SetProperty(ref _age, value);
89 private TimeSpan _bestTime;
99 if (SetProperty(ref _bestTime, value))
108 private bool _isTimeFromRudolphTable =
false;
116 get => _isTimeFromRudolphTable;
117 set => SetProperty(ref _isTimeFromRudolphTable, value);
120 private bool _isTimeInterpolatedFromRudolphTable =
false;
128 get => _isTimeInterpolatedFromRudolphTable;
129 set => SetProperty(ref _isTimeInterpolatedFromRudolphTable, value);
132 private bool _isOpenAgeTimeFromRudolphTable =
false;
140 get => _isOpenAgeTimeFromRudolphTable;
141 set => SetProperty(ref _isOpenAgeTimeFromRudolphTable, value);
144 private ushort _distance = 0;
154 if (SetProperty(ref _distance, value))
173 #region Other properties
175 private bool _hasDuplicates =
false;
183 get => _hasDuplicates;
184 set => SetProperty(ref _hasDuplicates, value);
191 #region SetPropertyFromString helper
201 switch (propertyName)
203 case nameof(
Id): dataObj.Id =
int.Parse(value);
break;
204 case nameof(
Gender):
if (EnumCoreLocalizedStringHelper.TryParse(value, out
Genders parsedGender)) { dataObj.Gender = parsedGender; }
break;
205 case nameof(
SwimmingStyle):
if (EnumCoreLocalizedStringHelper.TryParse(value, out
SwimmingStyles parsedStyle)) { dataObj.SwimmingStyle = parsedStyle; }
break;
206 case nameof(
Age): dataObj.Age =
byte.Parse(value);
break;
207 case nameof(
BestTime): dataObj.BestTime = TimeSpan.Parse(value);
break;
208 case nameof(
IsTimeFromRudolphTable): dataObj.IsTimeFromRudolphTable = !
string.IsNullOrEmpty(value);
break;
219 #region Equality, HashCode, ToString, Clone
227 => obj is
Competition c && (c.Id, c.Gender, c.SwimmingStyle, c.Age, c.BestTime, c.IsTimeFromRudolphTable, c.IsTimeInterpolatedFromRudolphTable, c.IsOpenAgeTimeFromRudolphTable).
Equals((
Id,
Gender,
SwimmingStyle,
Age,
BestTime,
IsTimeFromRudolphTable,
IsTimeInterpolatedFromRudolphTable,
IsOpenAgeTimeFromRudolphTable));
244 => base.GetHashCode();
252 => $
"{Id}: {Distance}m {SwimmingStyle} {Gender} (Age: {Age}{(IsTimeFromRudolphTable ? ", from rudolph table
" : "")}{(IsOpenAgeTimeFromRudolphTable ? " (open age)
" : "")}{(IsTimeInterpolatedFromRudolphTable ? ", interpolated from rudolph table
" : "")})";
override int GetHashCode()
Serves as the default hash function.
override bool Equals(object obj)
Compare if two Competitions are equal.
Genders Gender
Gender for this competition.
bool Equals(Competition other)
Indicates wheather the current object is equal to another object of the same type.
bool IsOpenAgeTimeFromRudolphTable
True, when the BestTime was the open age value taken from the RudolphTable.
ushort Distance
Distance in meters for this competition (e.g.
SwimmingStyles SwimmingStyle
Swimming style for this competition.
bool HasDuplicates
This flag indicates if there are duplicates of this in the competition list.
TimeSpan BestTime
Time for this competition to reach the maximum points.
byte Age
Age for the person that is assigned for this competition.
bool IsTimeInterpolatedFromRudolphTable
True, when the BestTime was an interpolated value based on the competitions with IsTimeFromRudolphTab...
static void SetPropertyFromString(Competition dataObj, string propertyName, string value)
Set the requested property in the Competition object by parsing the given string value.
bool IsTimeFromRudolphTable
True, when the BestTime was the value taken from the RudolphTable.
bool IsDistanceValid
Only true when the Distance is greater 0.
Competition()
Constructor for a new Competition object.
Competition(Competition other)
Clone constructor for a Competition object.
override string ToString()
Returns a string that represents the current object.
object Clone()
Create a new object that has the same property values than this one.
SwimmingStyles
Available swimming styles.
Genders
Available genders for a person.