Move common interface implementations to extension methods

This commit is contained in:
Dean Herbert
2021-10-05 14:41:14 +09:00
parent 1d99bc280f
commit d3b9660148
11 changed files with 91 additions and 91 deletions

View File

@ -2,8 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Localisation;
#nullable enable
@ -65,47 +63,6 @@ namespace osu.Game.Beatmaps
/// </summary>
string BackgroundFile { get; }
/// <summary>
/// A user-presentable display title representing this metadata.
/// </summary>
string DisplayTitle
{
get
{
string author = string.IsNullOrEmpty(Author) ? string.Empty : $"({Author})";
return $"{Artist} - {Title} {author}".Trim();
}
}
/// <summary>
/// A user-presentable display title representing this metadata, with localisation handling for potentially romanisable fields.
/// </summary>
RomanisableString DisplayTitleRomanisable
{
get
{
string author = string.IsNullOrEmpty(Author) ? string.Empty : $"({Author})";
var artistUnicode = string.IsNullOrEmpty(ArtistUnicode) ? Artist : ArtistUnicode;
var titleUnicode = string.IsNullOrEmpty(TitleUnicode) ? Title : TitleUnicode;
return new RomanisableString($"{artistUnicode} - {titleUnicode} {author}".Trim(), $"{Artist} - {Title} {author}".Trim());
}
}
/// <summary>
/// An array of all searchable terms provided in contained metadata.
/// </summary>
string[] SearchableTerms => new[]
{
Author,
Artist,
ArtistUnicode,
Title,
TitleUnicode,
Source,
Tags
}.Where(s => !string.IsNullOrEmpty(s)).ToArray();
bool IEquatable<IBeatmapMetadataInfo>.Equals(IBeatmapMetadataInfo? other)
{
if (other == null)