mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Refactors the add book slice and shared media contributor model across the stack
This commit is contained in:
1 parent
3a2c80b615
commit
9a71a6d32b
61 files changed
+5223
-1384
No files matched your search
-76
@@ -1,76 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the credit of a media contributor in a music media element, carrying the role the contributor played.
|
||||
/// The role carries both a free-form display name, as returned by the metadata providers, and the canonical category
|
||||
/// the display name normalizes to, so that roles describing the same kind of contribution are never treated as distinct.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{RoleDisplayName}")]
|
||||
public sealed class MediaContributorCredit : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the credited media contributor.
|
||||
/// </summary>
|
||||
public MediaContributorId ContributorId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name of the role the contributor played.
|
||||
/// </summary>
|
||||
public string RoleDisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the canonical category of the role the contributor played.
|
||||
/// </summary>
|
||||
public MediaContributorRoleCategory RoleCategory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributorCredit"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the credited media contributor.</param>
|
||||
/// <param name="roleDisplayName">The display name of the role the contributor played.</param>
|
||||
/// <param name="roleCategory">The canonical category of the role the contributor played.</param>
|
||||
private MediaContributorCredit(MediaContributorId contributorId, string roleDisplayName, MediaContributorRoleCategory roleCategory)
|
||||
{
|
||||
ContributorId = contributorId;
|
||||
RoleDisplayName = roleDisplayName;
|
||||
RoleCategory = roleCategory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorCredit"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the credited media contributor.</param>
|
||||
/// <param name="roleDisplayName">The display name of the role the contributor played.</param>
|
||||
/// <param name="roleCategory">The canonical category of the role the contributor played.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="MediaContributorCredit"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<MediaContributorCredit> Create(MediaContributorId contributorId, string roleDisplayName, MediaContributorRoleCategory roleCategory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(roleDisplayName))
|
||||
return Errors.Music.CreditRoleDisplayNameCannotBeEmpty;
|
||||
|
||||
return new MediaContributorCredit(contributorId, roleDisplayName, roleCategory);
|
||||
}
|
||||
|
||||
/// <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 ContributorId;
|
||||
yield return RoleDisplayName;
|
||||
yield return RoleCategory;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for a media contributor of a music media element, carrying the role the contributor played.
|
||||
/// The media contributor is identified only by its Id, duplicated from the Media Contributor bounded context, and the role is
|
||||
/// the canonical role the contributor played, used as the key of its localized display string.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Role}")]
|
||||
public sealed class MusicMediaContributor : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the media contributor.
|
||||
/// </summary>
|
||||
public MediaContributorId ContributorId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role the contributor played.
|
||||
/// </summary>
|
||||
public MediaContributorRole Role { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MusicMediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">The role the contributor played.</param>
|
||||
private MusicMediaContributor(MediaContributorId contributorId, MediaContributorRole role)
|
||||
{
|
||||
ContributorId = contributorId;
|
||||
Role = role;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MusicMediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">The role the contributor played.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="MusicMediaContributor"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<MusicMediaContributor> Create(MediaContributorId contributorId, MediaContributorRole role)
|
||||
{
|
||||
return new MusicMediaContributor(contributorId, role);
|
||||
}
|
||||
|
||||
/// <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 ContributorId;
|
||||
yield return Role;
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the role of a media contributor in a media item.
|
||||
/// The role carries both a free-form display name, as returned by the metadata providers, and the canonical
|
||||
/// category the display name normalizes to, so that roles describing the same kind of contribution are never
|
||||
/// treated as distinct.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DisplayName}")]
|
||||
public sealed class MediaContributorRole : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the display name of the role.
|
||||
/// </summary>
|
||||
public string DisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the canonical category of the role.
|
||||
/// </summary>
|
||||
public MediaContributorRoleCategory Category { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributorRole"/> class.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The display name of the role.</param>
|
||||
/// <param name="category">The canonical category of the role.</param>
|
||||
private MediaContributorRole(string displayName, MediaContributorRoleCategory category)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Category = category;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorRole"/> class, from a display <paramref name="displayName"/> and its canonical <paramref name="category"/>.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The display name of the role.</param>
|
||||
/// <param name="category">The canonical category of the role.</param>
|
||||
/// <returns>The created <see cref="MediaContributorRole"/> instance.</returns>
|
||||
public static Result<MediaContributorRole> Create(string displayName, MediaContributorRoleCategory category)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(displayName))
|
||||
return Errors.MediaContributors.MediaContributorRoleNameCannotBeEmpty;
|
||||
|
||||
return new MediaContributorRole(displayName, category);
|
||||
}
|
||||
|
||||
/// <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 DisplayName;
|
||||
yield return Category;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for a media contributor of a book, carrying the role the contributor played.
|
||||
/// The media contributor is identified only by its Id, duplicated from the Media Contributor bounded context, and the role is
|
||||
/// the canonical role the contributor played, used as the key of its localized display string.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Role}")]
|
||||
public sealed class BookMediaContributor : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the media contributor.
|
||||
/// </summary>
|
||||
public MediaContributorId ContributorId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role the contributor played.
|
||||
/// </summary>
|
||||
public MediaContributorRole Role { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookMediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">The role the contributor played.</param>
|
||||
private BookMediaContributor(MediaContributorId contributorId, MediaContributorRole role)
|
||||
{
|
||||
ContributorId = contributorId;
|
||||
Role = role;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookMediaContributor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">The role the contributor played.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="BookMediaContributor"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<BookMediaContributor> Create(MediaContributorId contributorId, MediaContributorRole role)
|
||||
{
|
||||
return new BookMediaContributor(contributorId, role);
|
||||
}
|
||||
|
||||
/// <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 ContributorId;
|
||||
yield return Role;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a media contributor, duplicated from the MediaContributor bounded context to keep the cross bounded context references decoupled.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class MediaContributorId : EntityId<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaContributorId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private MediaContributorId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
|
||||
public static MediaContributorId CreateUnique()
|
||||
{
|
||||
return new MediaContributorId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaContributorId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="MediaContributorId"/> instance.</param>
|
||||
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
|
||||
public static MediaContributorId Create(Guid value)
|
||||
{
|
||||
return new MediaContributorId(value);
|
||||
}
|
||||
|
||||
/// <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 Value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user