Nullable refernce types refactoring

This commit is contained in:
Mikhail Shabanov committed 2020-12-27 12:39:25 +01:00
1 parent e5c90e03d3
commit e12734981b
85 files changed
+509 -351

No files matched your search

@@ -1,4 +1,7 @@
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Model;
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
@@ -32,7 +35,8 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
///<summary>
/// Player's nick
///</summary>
public string Nickname { get; set; }
[Required]
public string Nickname { get; set; } = string.Empty;
///<summary>
/// Player information update date
@@ -19,14 +19,14 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
public int LastBattleTime { get; set; }
public bool Equals(AccountInfoHistoryKey other)
public bool Equals(AccountInfoHistoryKey? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return AccountId == other.AccountId && LastBattleTime == other.LastBattleTime;
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
@@ -7,7 +7,7 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
{
public TankInfo()
{
TankInfoId = new TankInfoKey();
}
public TankInfo(long accountId, long tankId)
@@ -7,7 +7,7 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
public TankInfoHistory()
{
TankInfoHistoryId = new TankInfoHistoryKey();
}
public TankInfoHistory(long accountId, long tankId, int lastBattleTime)
@@ -31,14 +31,14 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
///</summary>
public int LastBattleTime { get; set; }
public bool Equals(TankInfoHistoryKey other)
public bool Equals(TankInfoHistoryKey? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return AccountId == other.AccountId && TankId == other.TankId && LastBattleTime == other.LastBattleTime;
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
@@ -25,14 +25,14 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
///</summary>
public long TankId { get; set; }
public bool Equals(TankInfoKey other)
public bool Equals(TankInfoKey? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return AccountId == other.AccountId && TankId == other.TankId;
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -6,19 +7,18 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class AchievementDictionary : IAchievementDictionary
{
[BsonId]
public string AchievementId { get; set; }
public List<LocalizableString> Condition { get; set; }
public List<LocalizableString> Description { get; set; }
public List<LocalizableString> HeroInfo { get; set; }
public string Image { get; set; }
public string ImageBig { get; set; }
public List<LocalizableString> Name { get; set; }
[BsonId] public string AchievementId { get; set; } = string.Empty;
public List<LocalizableString> Condition { get; set; } = Enumerable.Empty<LocalizableString>().ToList();
public List<LocalizableString> Description { get; set; } = Enumerable.Empty<LocalizableString>().ToList();
public List<LocalizableString> HeroInfo { get; set; } = Enumerable.Empty<LocalizableString>().ToList();
public string Image { get; set; } = string.Empty;
public string ImageBig { get; set; } = string.Empty;
public List<LocalizableString> Name { get; set; } = Enumerable.Empty<LocalizableString>().ToList();
public long? Order { get; set; }
public bool Outdated { get; set; }
public string SectionId { get; set; }
public string SectionId { get; set; } = string.Empty;
public long? SectionOrder { get; set; }
public string Type { get; set; }
public List<AchievementOption> Options { get; set; }
public string Type { get; set; } = string.Empty;
public List<AchievementOption> Options { get; set; } = Enumerable.Empty<AchievementOption>().ToList();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -6,9 +7,10 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class AchievementSectionDictionary: IAchievementSectionDictionary
{
[BsonId]
public string AchievementSectionId { get; set; }
[BsonId] public string AchievementSectionId { get; set; } = string.Empty;
public int Order { get; set; }
public List<LocalizableString> AchievementSectionNames { get; set; }
public List<LocalizableString> AchievementSectionNames { get; set; } =
Enumerable.Empty<LocalizableString>().ToList();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -6,8 +7,8 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class ClanRoleDictionary : IClanRoleDictionary
{
[BsonId]
public string ClanRoleId { get; set; }
public List<LocalizableString> ClanRoleNames { get; set; }
[BsonId] public string ClanRoleId { get; set; } = string.Empty;
public List<LocalizableString> ClanRoleNames { get; set; } =
Enumerable.Empty<LocalizableString>().ToList();
}
}
@@ -5,9 +5,8 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class LanguageDictionary: ILanguageDictionary
{
[BsonId]
public string LanguageId { get; set; }
[BsonId] public string LanguageId { get; set; } = string.Empty;
public string LanguageName { get; set; }
public string LanguageName { get; set; } = string.Empty;
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -6,8 +7,8 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class NationDictionary : INationDictionary
{
[BsonId]
public string NationId { get; set; }
public List<LocalizableString> NationNames { get; set; }
[BsonId] public string NationId { get; set; } = string.Empty;
public List<LocalizableString> NationNames { get; set; } =
Enumerable.Empty<LocalizableString>().ToList();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -6,8 +7,8 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
public class VehicleTypeDictionary : IVehicleTypeDictionary
{
[BsonId]
public string VehicleTypeId { get; set; }
public List<LocalizableString> VehicleTypeNames { get; set; }
[BsonId] public string VehicleTypeId { get; set; } = string.Empty;
public List<LocalizableString> VehicleTypeNames { get; set; } = Enumerable.Empty<LocalizableString>().ToList();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Bson.Serialization.Attributes;
using WotBlitzStatisticsPro.Common.Dictionaries;
@@ -8,21 +9,25 @@ namespace WotBlitzStatisticsPro.DataAccess.Model
{
[BsonId]
public long TankId { get; set; }
public List<LocalizableString> Name { get; set; }
public List<LocalizableString> Description { get; set; }
public List<LocalizableString> Name { get; set; } =
Enumerable.Empty<LocalizableString>().ToList();
public List<LocalizableString> Description { get; set; } =
Enumerable.Empty<LocalizableString>().ToList();
public bool IsPremium { get; set; }
public string TypeId { get; set; }
public string NationId { get; set; }
public string TypeId { get; set; } = string.Empty;
public string NationId { get; set; } = string.Empty;
public int Tier { get; set; }
public string PreviewImage { get; set; }
public string NormalImage { get; set; }
public string PreviewImage { get; set; } = string.Empty;
public string NormalImage { get; set; } = string.Empty;
public decimal PriceCredit { get; set; }
public decimal PriceGold { get; set; }
public List<VehiclePriceInXp> NexTanksInTree { get; set; }
public List<VehiclePriceInXp> PriceXp { get; set; }
public int[] Engines { get; set; }
public int[] Guns { get; set; }
public int[] Suspensions { get; set; }
public int[] Turrets { get; set; }
public List<VehiclePriceInXp> NexTanksInTree { get; set; } =
Enumerable.Empty<VehiclePriceInXp>().ToList();
public List<VehiclePriceInXp> PriceXp { get; set; } =
Enumerable.Empty<VehiclePriceInXp>().ToList();
public int[]? Engines { get; set; }
public int[]? Guns { get; set; }
public int[]? Suspensions { get; set; }
public int[]? Turrets { get; set; }
}
}