Initialise all parameters is paramaterless constructor for now for added safety

This commit is contained in:
Dean Herbert 2022-01-17 13:51:30 +09:00
parent 11ca1b6e7b
commit 744084b418
2 changed files with 27 additions and 21 deletions

View File

@ -31,11 +31,11 @@ public class BeatmapInfo : RealmObject, IHasGuidPrimaryKey, IBeatmapInfo, IEquat
public string DifficultyName { get; set; } = string.Empty;
public RulesetInfo Ruleset { get; set; } = null!;
public RulesetInfo Ruleset { get; set; }
public BeatmapDifficulty Difficulty { get; set; } = new BeatmapDifficulty();
public BeatmapDifficulty Difficulty { get; set; }
public BeatmapMetadata Metadata { get; set; } = new BeatmapMetadata();
public BeatmapMetadata Metadata { get; set; }
[IgnoreMap]
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
@ -51,6 +51,9 @@ public BeatmapInfo(RulesetInfo ruleset, BeatmapDifficulty difficulty, BeatmapMet
[UsedImplicitly]
public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
{
Ruleset = new RulesetInfo();
Difficulty = new BeatmapDifficulty();
Metadata = new BeatmapMetadata();
}
public BeatmapSetInfo? BeatmapSet { get; set; }

View File

@ -32,19 +32,33 @@ public class ScoreInfo : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftD
[PrimaryKey]
public Guid ID { get; set; } = Guid.NewGuid();
public BeatmapInfo BeatmapInfo { get; set; }
public RulesetInfo Ruleset { get; set; }
public IList<RealmNamedFileUsage> Files { get; } = null!;
public string Hash { get; set; } = string.Empty;
public bool DeletePending { get; set; }
public bool Equals(ScoreInfo other) => other.ID == ID;
public long TotalScore { get; set; }
public int MaxCombo { get; set; }
public double Accuracy { get; set; }
public bool HasReplay { get; set; }
public DateTimeOffset Date { get; set; }
public double? PP { get; set; }
[Indexed]
public long OnlineID { get; set; } = -1;
[MapTo("User")]
public RealmUser RealmUser { get; set; } = new RealmUser();
public RealmUser RealmUser { get; set; }
[MapTo("Mods")]
public string ModsJson { get; set; } = string.Empty;
@ -62,6 +76,9 @@ public ScoreInfo(BeatmapInfo beatmap, RulesetInfo ruleset, RealmUser realmUser)
[UsedImplicitly]
public ScoreInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
{
Ruleset = new RulesetInfo();
RealmUser = new RealmUser();
BeatmapInfo = new BeatmapInfo();
}
// TODO: this is a bit temporary to account for the fact that this class is used to ferry API user data to certain UI components.
@ -88,22 +105,6 @@ public APIUser User
}
}
public long TotalScore { get; set; }
public int MaxCombo { get; set; }
public double Accuracy { get; set; }
public bool HasReplay { get; set; }
public DateTimeOffset Date { get; set; }
public double? PP { get; set; }
public BeatmapInfo BeatmapInfo { get; set; } = null!;
public RulesetInfo Ruleset { get; set; } = null!;
public ScoreRank Rank
{
get => (ScoreRank)RankInt;
@ -275,6 +276,8 @@ public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
#endregion
public bool Equals(ScoreInfo other) => other.ID == ID;
public override string ToString() => this.GetDisplayTitle();
}
}