//protected void MakeInvalid() => IsValid = false; //protected void MakeValid() => IsValid = true; protected void AddInvalidReason(bool condition, string reason) { if (!condition) { return; } InvalidReasons.Add(reason); IsValid = false; }
public bool IsValid() { return(!InvalidReasons.Any()); }
private string ToStringFull() { var sb = new StringBuilder(1024); sb.Append(TeamName.SanitizeToCsv()); sb.Append(","); sb.Append(GamerTag.SanitizeToCsv()); sb.Append(","); if (!string.IsNullOrWhiteSpace(CheckedInAt)) { sb.Append(CheckedInAt.SanitizeToCsv()); } sb.Append(","); if (!string.IsNullOrWhiteSpace(TeamNameAgain)) { sb.Append(TeamNameAgain.SanitizeToCsv()); } sb.Append(","); if (!string.IsNullOrWhiteSpace(ClanTag)) { sb.Append(ClanTag.SanitizeToCsv()); } sb.Append(","); if (!string.IsNullOrWhiteSpace(ClanUrl)) { sb.Append(ClanUrl.SanitizeToCsv()); } sb.Append(","); if (!string.IsNullOrWhiteSpace(PreferredServer)) { sb.Append(PreferredServer.SanitizeToCsv()); } sb.Append(","); if (!string.IsNullOrWhiteSpace(AlternateServer)) { sb.Append(AlternateServer.SanitizeToCsv()); } sb.Append(","); if (TeamContactMailAddress != null) { sb.Append(TeamContactMailAddress.Address.SanitizeToCsv()); } sb.Append(","); // new fields sb.Append(OriginalLine); sb.Append(","); sb.Append(IsValid ? "1" : "0"); sb.Append(","); if (!IsValid) { sb.Append(InvalidReasons.SanitizeToCsv()); } sb.Append(","); if (ClanId.HasValue) { sb.Append(ClanId.Value); } sb.Append(","); if (Player != null) { sb.Append(Player.Id); } sb.Append(","); if (Player?.CurrentClanId != null) { sb.Append(Player.CurrentClanId.Value); } sb.Append(","); if (Player?.CurrentClanTag != null) { sb.Append(Player.CurrentClanTag); } sb.Append(","); if (Player != null) { sb.Append(Player.Moment.ToString("yyyy-MM-dd HH:mm:ss")); } sb.Append(","); sb.Append(PreferredServerLocation); sb.Append(","); sb.Append(AlternateServerLocation); sb.Append(","); if (Player == null) { sb.Append(",,,,,,,"); } else { sb.Append($"{Player.Battles.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.WinRate.ToString("N4", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.AvgTier.ToString("N2", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Wn8.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10Battles.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10WinRate.ToString("N4", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10Wn8.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10DirectDamage.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}"); } return(sb.ToString()); }
private string ToStringSimple() { var sb = new StringBuilder(1024); sb.Append(GamerTag.SanitizeToCsv()); sb.Append(","); sb.Append(TeamName.SanitizeToCsv()); sb.Append(","); if (!string.IsNullOrWhiteSpace(ClanTag)) { sb.Append(ClanTag.SanitizeToCsv()); } sb.Append(","); // new fields sb.Append(OriginalLine); sb.Append(","); // Division sb.Append(","); // Group sb.Append(","); sb.Append(IsValid ? "1" : "0"); sb.Append(","); if (!IsValid) { sb.Append(InvalidReasons.SanitizeToCsv()); } sb.Append(","); if (ClanId.HasValue) { sb.Append(ClanId.Value); } sb.Append(","); if (Player != null) { sb.Append(Player.Id); } sb.Append(","); if (Player?.CurrentClanId != null) { sb.Append(Player.CurrentClanId.Value); } sb.Append(","); if (Player?.CurrentClanTag != null) { sb.Append(Player.CurrentClanTag); } sb.Append(","); if (Player != null) { sb.Append(Player.Moment.ToString("yyyy-MM-dd HH:mm:ss")); } sb.Append(","); if (Player == null) { sb.Append(",,,,,,,"); } else { sb.Append($"{Player.Battles.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.WinRate.ToString("N4", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.AvgTier.ToString("N2", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Wn8.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10Battles.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10WinRate.ToString("N4", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10Wn8.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}," + $"{Player.Tier10DirectDamage.ToString("N0", CultureInfo.InvariantCulture).SanitizeToCsv()}"); } return(sb.ToString()); }