Moved some classes around to the domain layer.
This commit is contained in:
@@ -16,25 +16,6 @@ public static class DLSiteToDomainMapper
|
||||
private const string OptAIFull = "AIG";
|
||||
private const string OptAIPartial = "AIP";
|
||||
|
||||
private static readonly (string Code, Language Lang)[] SupportedLanguageFlags =
|
||||
[
|
||||
(SupportedLanguage.Japanese.Code, Language.Japanese),
|
||||
(SupportedLanguage.English.Code, Language.English),
|
||||
(SupportedLanguage.ChineseTraditional.Code, Language.ChineseTraditional),
|
||||
(SupportedLanguage.ChineseSimplified.Code, Language.ChineseSimplified)
|
||||
];
|
||||
|
||||
private static readonly (string Code, SupportedLanguage Lang)[] SupportedLanguageFlags2 =
|
||||
[
|
||||
(SupportedLanguage.Japanese.Code, SupportedLanguage.Japanese),
|
||||
(SupportedLanguage.English.Code, SupportedLanguage.English),
|
||||
(SupportedLanguage.ChineseTraditional.Code, SupportedLanguage.ChineseTraditional),
|
||||
(SupportedLanguage.ChineseSimplified.Code, SupportedLanguage.ChineseSimplified)
|
||||
];
|
||||
|
||||
private static readonly Dictionary<string, Language> TranslationLanguageMap =
|
||||
SupportedLanguageFlags.ToDictionary(x => x.Code, x => x.Lang, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static readonly Dictionary<int, AgeRating> AgeRatingMap = new()
|
||||
{
|
||||
{ 1, AgeRating.AllAges },
|
||||
@@ -89,11 +70,10 @@ public static class DLSiteToDomainMapper
|
||||
if (string.IsNullOrWhiteSpace(productInfo.TitleId) || string.IsNullOrWhiteSpace(productInfo.TitleName))
|
||||
return null;
|
||||
|
||||
return new VoiceWorkSeries
|
||||
{
|
||||
Identifier = productInfo.TitleId,
|
||||
Name = productInfo.TitleName
|
||||
};
|
||||
return new VoiceWorkSeries(
|
||||
Identifier: productInfo.TitleId,
|
||||
Name: productInfo.TitleName
|
||||
);
|
||||
}
|
||||
|
||||
private static VoiceWorkTranslation? MapTranslation(ProductInfo info, HashSet<string> options)
|
||||
@@ -108,30 +88,37 @@ public static class DLSiteToDomainMapper
|
||||
if (!options.Contains(languageCode))
|
||||
return null;
|
||||
|
||||
if (!TranslationLanguageMap.TryGetValue(languageCode, out Language language))
|
||||
if (!SupportedLanguage.TryFromCode(languageCode, out SupportedLanguage? supportedLanguage))
|
||||
return null;
|
||||
|
||||
string originalId = translationInfo.OriginalWorkNumber;
|
||||
bool isOfficial = options.Contains(OptOfficialTranslation);
|
||||
bool isRecommended = options.Contains(OptRecommendedTranslation);
|
||||
|
||||
return new VoiceWorkTranslation
|
||||
{
|
||||
OriginalProductId = originalId,
|
||||
Language = language,
|
||||
IsOfficialTranslation = isOfficial,
|
||||
IsRecommendedTranslation = isRecommended
|
||||
};
|
||||
TranslationKind translationKind = TranslationKind.None;
|
||||
|
||||
if (options.Contains(OptOfficialTranslation))
|
||||
translationKind |= TranslationKind.Official;
|
||||
|
||||
if (options.Contains(OptRecommendedTranslation))
|
||||
translationKind |= TranslationKind.Recommended;
|
||||
|
||||
//bool isOfficial = options.Contains(OptOfficialTranslation);
|
||||
//bool isRecommended = options.Contains(OptRecommendedTranslation);
|
||||
|
||||
return new VoiceWorkTranslation(
|
||||
OriginalProductId: originalId,
|
||||
Language: supportedLanguage.Language,
|
||||
Kind: translationKind
|
||||
);
|
||||
}
|
||||
|
||||
private static SupportedLanguage[] MapSupportedLanguages(HashSet<string> options)
|
||||
{
|
||||
List<SupportedLanguage> languages = [];
|
||||
|
||||
foreach (var (code, language) in SupportedLanguageFlags2)
|
||||
foreach (SupportedLanguage supportedLanguage in SupportedLanguage.All)
|
||||
{
|
||||
if (options.Contains(code) && !languages.Contains(language))
|
||||
languages.Add(language);
|
||||
if (options.Contains(supportedLanguage.Code) && !languages.Contains(supportedLanguage))
|
||||
languages.Add(supportedLanguage);
|
||||
}
|
||||
|
||||
return [.. languages];
|
||||
|
||||
Reference in New Issue
Block a user