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]
[Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey
public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
{
public int ID { get; set; }
public int BeatmapVersion;
private int? onlineBeatmapID;
private IRulesetInfo ruleset;
[JsonProperty("id")]
public int? OnlineBeatmapID
@ -187,5 +188,21 @@ public bool BackgroundEquals(BeatmapInfo other) => other != null && BeatmapSet !
/// Returns a shallow-clone of this <see cref="BeatmapInfo"/>.
/// </summary>
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]
[Serializable]
public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey
public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
{
public int ID { get; set; }
@ -128,5 +128,7 @@ public bool Equals(BeatmapMetadata other)
&& AudioFile == other.AudioFile
&& BackgroundFile == other.BackgroundFile;
}
string IBeatmapMetadataInfo.Author => AuthorString;
}
}

View File

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

View File

@ -12,7 +12,7 @@
namespace osu.Game.Beatmaps
{
[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; }
@ -90,5 +90,19 @@ public bool Equals(BeatmapSetInfo 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.
using osu.Framework.Localisation;
using osu.Game.Database;
using osu.Game.Rulesets;
#nullable enable

View File

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

View File

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

View File

@ -1,9 +1,11 @@
// 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.
using osu.Game.IO;
#nullable enable
namespace osu.Game.Beatmaps
namespace osu.Game.Database
{
/// <summary>
/// A usage of a file, with a local filename attached.

View File

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

View File

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

View File

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

View File

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