mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds first value objects of the domain
This commit is contained in:
1 parent
1e902e47dc
commit
12de2b27f0
19 files changed
+1207
-58
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the genres of a media element.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Name}")]
|
||||
public class Genre : ValueObject
|
||||
{
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
/// <summary>
|
||||
/// Gets the name of the genre element of the media item.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
#endregion
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Overload C-tor.
|
||||
/// </summary>
|
||||
/// <param name="name">The value representing this object.</param>
|
||||
private Genre(string name)
|
||||
{
|
||||
Name = name.Trim();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">The value of the genre.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{T}"/> containing either a successfully created <see cref="Genre"/> or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Genre> Create(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return Errors.Errors.Metadata.GenreCannotBeEmpty;
|
||||
return new Genre(name);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customized ToString() method.
|
||||
/// </summary>
|
||||
/// <returns>Custom string value showing relevant data for current class.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user