1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 19:32:55 +08:00

Update all EF based models to implement new read only interfaces

This commit is contained in:
Dean Herbert 2021-10-01 16:31:11 +09:00
parent 619dfe0690
commit d309636460
12 changed files with 57 additions and 11 deletions

View File

@ -17,13 +17,14 @@ namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
[Serializable] [Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
{ {
public int ID { get; set; } public int ID { get; set; }
public int BeatmapVersion; public int BeatmapVersion;
private int? onlineBeatmapID; private int? onlineBeatmapID;
private IRulesetInfo ruleset;
[JsonProperty("id")] [JsonProperty("id")]
public int? OnlineBeatmapID public int? OnlineBeatmapID
@ -187,5 +188,21 @@ namespace osu.Game.Beatmaps
/// Returns a shallow-clone of this <see cref="BeatmapInfo"/>. /// Returns a shallow-clone of this <see cref="BeatmapInfo"/>.
/// </summary> /// </summary>
public BeatmapInfo Clone() => (BeatmapInfo)MemberwiseClone(); public BeatmapInfo Clone() => (BeatmapInfo)MemberwiseClone();
#region Implementation of IHasOnlineID
public int? OnlineID => ID;
#endregion
#region Implementation of IBeatmapInfo
public string DifficultyName => Version;
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
public IBeatmapDifficultyInfo Difficulty => BaseDifficulty;
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
public double StarRating => StarDifficulty;
#endregion
} }
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
[Serializable] [Serializable]
public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
{ {
public int ID { get; set; } public int ID { get; set; }
@ -128,5 +128,7 @@ namespace osu.Game.Beatmaps
&& AudioFile == other.AudioFile && AudioFile == other.AudioFile
&& BackgroundFile == other.BackgroundFile; && BackgroundFile == other.BackgroundFile;
} }
string IBeatmapMetadataInfo.Author => AuthorString;
} }
} }

View File

@ -7,7 +7,7 @@ using osu.Game.IO;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public class BeatmapSetFileInfo : INamedFileInfo, IHasPrimaryKey public class BeatmapSetFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{ {
public int ID { get; set; } public int ID { get; set; }
@ -19,5 +19,7 @@ namespace osu.Game.Beatmaps
[Required] [Required]
public string Filename { get; set; } public string Filename { get; set; }
public IFileInfo File => FileInfo;
} }
} }

View File

@ -12,7 +12,7 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class BeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<BeatmapSetInfo> public class BeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<BeatmapSetInfo>, IBeatmapSetInfo
{ {
public int ID { get; set; } public int ID { get; set; }
@ -90,5 +90,19 @@ namespace osu.Game.Beatmaps
return ReferenceEquals(this, other); return ReferenceEquals(this, other);
} }
#region Implementation of IHasOnlineID
public int? OnlineID => ID;
#endregion
#region Implementation of IBeatmapSetInfo
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata;
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
#endregion
} }
} }

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Database;
using osu.Game.Rulesets;
#nullable enable #nullable enable

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Database;
#nullable enable #nullable enable

View File

@ -3,7 +3,7 @@
#nullable enable #nullable enable
namespace osu.Game.Beatmaps namespace osu.Game.Database
{ {
public interface IHasOnlineID public interface IHasOnlineID
{ {

View File

@ -1,9 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.IO;
#nullable enable #nullable enable
namespace osu.Game.Beatmaps namespace osu.Game.Database
{ {
/// <summary> /// <summary>
/// A usage of a file, with a local filename attached. /// A usage of a file, with a local filename attached.

View File

@ -6,7 +6,7 @@ using osu.Game.Database;
namespace osu.Game.IO namespace osu.Game.IO
{ {
public class FileInfo : IHasPrimaryKey public class FileInfo : IHasPrimaryKey, IFileInfo
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@ -3,7 +3,7 @@
#nullable enable #nullable enable
namespace osu.Game.Beatmaps namespace osu.Game.IO
{ {
/// <summary> /// <summary>
/// A representation of a tracked file. /// A representation of a tracked file.

View File

@ -2,11 +2,11 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osu.Game.Rulesets; using osu.Game.Database;
#nullable enable #nullable enable
namespace osu.Game.Beatmaps namespace osu.Game.Rulesets
{ {
/// <summary> /// <summary>
/// A representation of a ruleset's metadata. /// A representation of a ruleset's metadata.

View File

@ -10,7 +10,7 @@ using osu.Framework.Testing;
namespace osu.Game.Rulesets namespace osu.Game.Rulesets
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class RulesetInfo : IEquatable<RulesetInfo> public class RulesetInfo : IEquatable<RulesetInfo>, IRulesetInfo
{ {
public int? ID { get; set; } public int? ID { get; set; }
@ -54,5 +54,11 @@ namespace osu.Game.Rulesets
} }
public override string ToString() => Name ?? $"{Name} ({ShortName}) ID: {ID}"; public override string ToString() => Name ?? $"{Name} ({ShortName}) ID: {ID}";
#region Implementation of IHasOnlineID
public int? OnlineID => ID;
#endregion
} }
} }