mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Adds the music artist alias, area, and work value objects and their enumerations
This commit is contained in:
1 parent
bf8b49653d
commit
e20e244a04
12 files changed
+1389
No files matched your search
+111
@@ -0,0 +1,111 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for a MusicBrainz area, the geographic area a music artist is associated with.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public sealed class MusicArea : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the MusicBrainz identifier of the area.
|
||||
/// </summary>
|
||||
public MusicBrainzId MusicBrainzAreaId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the area.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional sort name of the area.
|
||||
/// </summary>
|
||||
public Optional<string> SortName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional disambiguation comment of the area.
|
||||
/// </summary>
|
||||
public Optional<string> Disambiguation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional MusicBrainz type of the area (e.g., Country, City).
|
||||
/// </summary>
|
||||
public Optional<string> Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional ISO 3166 code of the area.
|
||||
/// </summary>
|
||||
public Optional<string> Iso3166Code { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicArea"/> class.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzAreaId">The MusicBrainz identifier of the area.</param>
|
||||
/// <param name="name">The name of the area.</param>
|
||||
/// <param name="sortName">The optional sort name of the area.</param>
|
||||
/// <param name="disambiguation">The optional disambiguation comment of the area.</param>
|
||||
/// <param name="type">The optional MusicBrainz type of the area.</param>
|
||||
/// <param name="iso3166Code">The optional ISO 3166 code of the area.</param>
|
||||
private MusicArea(
|
||||
MusicBrainzId musicBrainzAreaId,
|
||||
string name,
|
||||
Optional<string> sortName,
|
||||
Optional<string> disambiguation,
|
||||
Optional<string> type,
|
||||
Optional<string> iso3166Code)
|
||||
{
|
||||
MusicBrainzAreaId = musicBrainzAreaId;
|
||||
Name = name;
|
||||
SortName = sortName;
|
||||
Disambiguation = disambiguation;
|
||||
Type = type;
|
||||
Iso3166Code = iso3166Code;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MusicArea"/> class.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzAreaId">The MusicBrainz identifier of the area.</param>
|
||||
/// <param name="name">The name of the area.</param>
|
||||
/// <param name="sortName">The optional sort name of the area.</param>
|
||||
/// <param name="disambiguation">The optional disambiguation comment of the area.</param>
|
||||
/// <param name="type">The optional MusicBrainz type of the area.</param>
|
||||
/// <param name="iso3166Code">The optional ISO 3166 code of the area.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="MusicArea"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<MusicArea> Create(
|
||||
MusicBrainzId musicBrainzAreaId,
|
||||
string name,
|
||||
Optional<string> sortName,
|
||||
Optional<string> disambiguation,
|
||||
Optional<string> type,
|
||||
Optional<string> iso3166Code)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return Errors.Music.AreaNameCannotBeEmpty;
|
||||
|
||||
return new MusicArea(musicBrainzAreaId, name.Trim(), sortName, disambiguation, type, iso3166Code);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return MusicBrainzAreaId;
|
||||
yield return Name;
|
||||
yield return SortName;
|
||||
yield return Disambiguation;
|
||||
yield return Type;
|
||||
yield return Iso3166Code;
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for an alternative name of a music artist.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public sealed class MusicArtistAlias : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the alias.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional sort name of the alias.
|
||||
/// </summary>
|
||||
public Optional<string> SortName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional type of the alias (e.g., Artist name, Search hint).
|
||||
/// </summary>
|
||||
public Optional<string> Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional locale the alias is used in.
|
||||
/// </summary>
|
||||
public Optional<string> Locale { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this is the primary alias of the artist.
|
||||
/// </summary>
|
||||
public bool IsPrimary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional date the alias began being used.
|
||||
/// </summary>
|
||||
public Optional<DateOnly> BeginDate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional date the alias stopped being used.
|
||||
/// </summary>
|
||||
public Optional<DateOnly> EndDate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the alias is no longer used.
|
||||
/// </summary>
|
||||
public bool IsEnded { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicArtistAlias"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the alias.</param>
|
||||
/// <param name="sortName">The optional sort name of the alias.</param>
|
||||
/// <param name="type">The optional type of the alias.</param>
|
||||
/// <param name="locale">The optional locale the alias is used in.</param>
|
||||
/// <param name="isPrimary">Whether this is the primary alias of the artist.</param>
|
||||
/// <param name="beginDate">The optional date the alias began being used.</param>
|
||||
/// <param name="endDate">The optional date the alias stopped being used.</param>
|
||||
/// <param name="isEnded">Whether the alias is no longer used.</param>
|
||||
private MusicArtistAlias(
|
||||
string name,
|
||||
Optional<string> sortName,
|
||||
Optional<string> type,
|
||||
Optional<string> locale,
|
||||
bool isPrimary,
|
||||
Optional<DateOnly> beginDate,
|
||||
Optional<DateOnly> endDate,
|
||||
bool isEnded)
|
||||
{
|
||||
Name = name;
|
||||
SortName = sortName;
|
||||
Type = type;
|
||||
Locale = locale;
|
||||
IsPrimary = isPrimary;
|
||||
BeginDate = beginDate;
|
||||
EndDate = endDate;
|
||||
IsEnded = isEnded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MusicArtistAlias"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the alias.</param>
|
||||
/// <param name="sortName">The optional sort name of the alias.</param>
|
||||
/// <param name="type">The optional type of the alias.</param>
|
||||
/// <param name="locale">The optional locale the alias is used in.</param>
|
||||
/// <param name="isPrimary">Whether this is the primary alias of the artist.</param>
|
||||
/// <param name="beginDate">The optional date the alias began being used.</param>
|
||||
/// <param name="endDate">The optional date the alias stopped being used.</param>
|
||||
/// <param name="isEnded">Whether the alias is no longer used.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="MusicArtistAlias"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<MusicArtistAlias> Create(
|
||||
string name,
|
||||
Optional<string> sortName,
|
||||
Optional<string> type,
|
||||
Optional<string> locale,
|
||||
bool isPrimary,
|
||||
Optional<DateOnly> beginDate,
|
||||
Optional<DateOnly> endDate,
|
||||
bool isEnded)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return Errors.Music.ArtistAliasNameCannotBeEmpty;
|
||||
|
||||
return new MusicArtistAlias(name.Trim(), sortName, type, locale, isPrimary, beginDate, endDate, isEnded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Name;
|
||||
yield return SortName;
|
||||
yield return Type;
|
||||
yield return Locale;
|
||||
yield return IsPrimary;
|
||||
yield return BeginDate;
|
||||
yield return EndDate;
|
||||
yield return IsEnded;
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for a MusicBrainz work, the musical composition a track is a recording of.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Title}")]
|
||||
public sealed class MusicWork : ValueObject
|
||||
{
|
||||
private readonly List<LanguageInfo> _languages;
|
||||
private readonly List<string> _iswcs;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MusicBrainz identifier of the work.
|
||||
/// </summary>
|
||||
public MusicBrainzId MusicBrainzWorkId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the work.
|
||||
/// </summary>
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional MusicBrainz type of the work (e.g., Song).
|
||||
/// </summary>
|
||||
public Optional<string> Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of languages of the work.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<LanguageInfo> Languages => _languages.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ISWC (International Standard Musical Work Code) of the work.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<string> Iswcs => _iswcs.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicWork"/> class.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzWorkId">The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="title">The title of the work.</param>
|
||||
/// <param name="type">The optional MusicBrainz type of the work.</param>
|
||||
/// <param name="languages">The list of languages of the work.</param>
|
||||
/// <param name="iswcs">The list of ISWC of the work.</param>
|
||||
private MusicWork(
|
||||
MusicBrainzId musicBrainzWorkId,
|
||||
string title,
|
||||
Optional<string> type,
|
||||
List<LanguageInfo> languages,
|
||||
List<string> iswcs)
|
||||
{
|
||||
MusicBrainzWorkId = musicBrainzWorkId;
|
||||
Title = title;
|
||||
Type = type;
|
||||
_languages = languages;
|
||||
_iswcs = iswcs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MusicWork"/> class.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzWorkId">The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="title">The title of the work.</param>
|
||||
/// <param name="type">The optional MusicBrainz type of the work.</param>
|
||||
/// <param name="languages">The list of languages of the work.</param>
|
||||
/// <param name="iswcs">The list of ISWC of the work.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="MusicWork"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<MusicWork> Create(
|
||||
MusicBrainzId musicBrainzWorkId,
|
||||
string title,
|
||||
Optional<string> type,
|
||||
List<LanguageInfo> languages,
|
||||
List<string> iswcs)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(title))
|
||||
return Errors.Music.WorkTitleCannotBeEmpty;
|
||||
|
||||
return new MusicWork(musicBrainzWorkId, title.Trim(), type, languages, iswcs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return MusicBrainzWorkId;
|
||||
yield return Title;
|
||||
yield return Type;
|
||||
foreach (LanguageInfo language in _languages)
|
||||
yield return language;
|
||||
foreach (string iswc in _iswcs)
|
||||
yield return iswc;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user