Moved relevant application layer enums and value objects to the domain layer.
This commit is contained in:
8
JSMR.Domain/Enums/AIGeneration.cs
Normal file
8
JSMR.Domain/Enums/AIGeneration.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace JSMR.Domain.Enums;
|
||||
|
||||
public enum AIGeneration
|
||||
{
|
||||
None = 0,
|
||||
Partial = 1,
|
||||
Full = 2
|
||||
}
|
||||
8
JSMR.Domain/Enums/AgeRating.cs
Normal file
8
JSMR.Domain/Enums/AgeRating.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace JSMR.Domain.Enums;
|
||||
|
||||
public enum AgeRating
|
||||
{
|
||||
AllAges = 1,
|
||||
R15 = 2,
|
||||
R18 = 3
|
||||
}
|
||||
11
JSMR.Domain/Enums/Language.cs
Normal file
11
JSMR.Domain/Enums/Language.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace JSMR.Domain.Enums;
|
||||
|
||||
public enum Language
|
||||
{
|
||||
Unknown = -1,
|
||||
Japanese = 0,
|
||||
English = 1,
|
||||
ChineseSimplified = 2,
|
||||
ChineseTraditional = 3,
|
||||
Korean = 4
|
||||
}
|
||||
9
JSMR.Domain/Enums/VoiceWorkStatus.cs
Normal file
9
JSMR.Domain/Enums/VoiceWorkStatus.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace JSMR.Domain.Enums;
|
||||
|
||||
public enum VoiceWorkStatus
|
||||
{
|
||||
Available = 0,
|
||||
Upcoming = 1,
|
||||
NewRelease = 2,
|
||||
NewAndUpcoming = 3
|
||||
}
|
||||
39
JSMR.Domain/ValueObjects/SupportedLanguage.cs
Normal file
39
JSMR.Domain/ValueObjects/SupportedLanguage.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using JSMR.Domain.Enums;
|
||||
|
||||
namespace JSMR.Domain.ValueObjects;
|
||||
|
||||
public sealed record SupportedLanguage(string Code, Language Language)
|
||||
{
|
||||
public static readonly SupportedLanguage Japanese = new("JPN", Language.Japanese);
|
||||
public static readonly SupportedLanguage English = new("ENG", Language.English);
|
||||
public static readonly SupportedLanguage ChineseSimplified = new("CHI_HANS", Language.ChineseSimplified);
|
||||
public static readonly SupportedLanguage ChineseTraditional = new("CHI_HANT", Language.ChineseTraditional);
|
||||
public static readonly SupportedLanguage Korean = new("KO_KR", Language.Korean);
|
||||
public static readonly SupportedLanguage Alingual = new("NM", Language.Unknown);
|
||||
|
||||
public static IReadOnlyList<SupportedLanguage> All =>
|
||||
[
|
||||
Japanese,
|
||||
English,
|
||||
ChineseSimplified,
|
||||
ChineseTraditional,
|
||||
Korean
|
||||
];
|
||||
|
||||
private static readonly Dictionary<string, SupportedLanguage> _byCode =
|
||||
All.ToDictionary(x => x.Code, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly Dictionary<Language, SupportedLanguage> _byLang =
|
||||
All.ToDictionary(x => x.Language);
|
||||
|
||||
public static bool TryFromCode(string code, out SupportedLanguage? supportedLanguage) =>
|
||||
_byCode.TryGetValue(code, out supportedLanguage);
|
||||
|
||||
public static bool TryFromLanguage(Language lang, out SupportedLanguage? supportedLanguage) =>
|
||||
_byLang.TryGetValue(lang, out supportedLanguage);
|
||||
|
||||
public static SupportedLanguage FromLanguage(Language language) =>
|
||||
_byLang.TryGetValue(language, out var sl)
|
||||
? sl
|
||||
: throw new ArgumentOutOfRangeException(nameof(language), $"Unsupported: {language}");
|
||||
}
|
||||
Reference in New Issue
Block a user