mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 13:22:56 +08:00
Avoid constructor overhead for realm BeatmapSetInfo
parameterless constructor
This commit is contained in:
parent
3c852e6d02
commit
ccddf9b47d
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
@ -19,7 +20,7 @@ namespace osu.Game.Beatmaps
|
|||||||
public class BeatmapSetInfo : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftDelete, IEquatable<BeatmapSetInfo>, IBeatmapSetInfo
|
public class BeatmapSetInfo : RealmObject, IHasGuidPrimaryKey, IHasRealmFiles, ISoftDelete, IEquatable<BeatmapSetInfo>, IBeatmapSetInfo
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public Guid ID { get; set; } = Guid.NewGuid();
|
public Guid ID { get; set; }
|
||||||
|
|
||||||
[Indexed]
|
[Indexed]
|
||||||
public int OnlineID { get; set; } = -1;
|
public int OnlineID { get; set; } = -1;
|
||||||
@ -57,6 +58,19 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public double MaxBPM => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.BPM);
|
public double MaxBPM => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.BPM);
|
||||||
|
|
||||||
|
public BeatmapSetInfo(IEnumerable<BeatmapInfo>? beatmaps = null)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
ID = Guid.NewGuid();
|
||||||
|
if (beatmaps != null)
|
||||||
|
Beatmaps.AddRange(beatmaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly] // Realm
|
||||||
|
private BeatmapSetInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
|
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
|
||||||
/// The path returned is relative to the user file storage.
|
/// The path returned is relative to the user file storage.
|
||||||
|
@ -48,6 +48,7 @@ namespace osu.Game.Database
|
|||||||
copyChangesToRealm(s.Metadata, d.Metadata);
|
copyChangesToRealm(s.Metadata, d.Metadata);
|
||||||
});
|
});
|
||||||
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
|
.ConstructUsing(_ => new BeatmapSetInfo(null))
|
||||||
.ForMember(s => s.Beatmaps, cc => cc.Ignore())
|
.ForMember(s => s.Beatmaps, cc => cc.Ignore())
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
@ -77,6 +78,7 @@ namespace osu.Game.Database
|
|||||||
applyCommonConfiguration(c);
|
applyCommonConfiguration(c);
|
||||||
|
|
||||||
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
|
.ConstructUsing(_ => new BeatmapSetInfo(null))
|
||||||
.MaxDepth(2)
|
.MaxDepth(2)
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
{
|
{
|
||||||
@ -109,6 +111,7 @@ namespace osu.Game.Database
|
|||||||
applyCommonConfiguration(c);
|
applyCommonConfiguration(c);
|
||||||
|
|
||||||
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
|
||||||
|
.ConstructUsing(_ => new BeatmapSetInfo(null))
|
||||||
.MaxDepth(2)
|
.MaxDepth(2)
|
||||||
.ForMember(b => b.Files, cc => cc.Ignore())
|
.ForMember(b => b.Files, cc => cc.Ignore())
|
||||||
.AfterMap((s, d) =>
|
.AfterMap((s, d) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user