mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 10:33:07 +08:00
Avoid constructor overhead for realm ScoreInfo
parameterless constructor
This commit is contained in:
parent
3faf980fed
commit
3c852e6d02
@ -29,11 +29,11 @@ namespace osu.Game.Scoring
|
||||
public class ScoreInfo : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftDelete, IEquatable<ScoreInfo>, IScoreInfo
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid ID { get; set; } = Guid.NewGuid();
|
||||
public Guid ID { get; set; }
|
||||
|
||||
public BeatmapInfo BeatmapInfo { get; set; }
|
||||
public BeatmapInfo BeatmapInfo { get; set; } = null!;
|
||||
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
public RulesetInfo Ruleset { get; set; } = null!;
|
||||
|
||||
public IList<RealmNamedFileUsage> Files { get; } = null!;
|
||||
|
||||
@ -57,7 +57,7 @@ namespace osu.Game.Scoring
|
||||
public long OnlineID { get; set; } = -1;
|
||||
|
||||
[MapTo("User")]
|
||||
public RealmUser RealmUser { get; set; }
|
||||
public RealmUser RealmUser { get; set; } = null!;
|
||||
|
||||
[MapTo("Mods")]
|
||||
public string ModsJson { get; set; } = string.Empty;
|
||||
@ -65,19 +65,17 @@ namespace osu.Game.Scoring
|
||||
[MapTo("Statistics")]
|
||||
public string StatisticsJson { get; set; } = string.Empty;
|
||||
|
||||
public ScoreInfo(BeatmapInfo beatmap, RulesetInfo ruleset, RealmUser realmUser)
|
||||
public ScoreInfo(BeatmapInfo? beatmap = null, RulesetInfo? ruleset = null, RealmUser? realmUser = null)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
BeatmapInfo = beatmap;
|
||||
RealmUser = realmUser;
|
||||
Ruleset = ruleset ?? new RulesetInfo();
|
||||
BeatmapInfo = beatmap ?? new BeatmapInfo();
|
||||
RealmUser = realmUser ?? new RealmUser();
|
||||
ID = Guid.NewGuid();
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public ScoreInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
|
||||
[UsedImplicitly] // Realm
|
||||
private ScoreInfo()
|
||||
{
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user