SHA256
GuestLog - Small improvements and changes in localization for DataLists.
This commit is contained in:
@@ -6,4 +6,6 @@ public interface IDataListService
|
||||
public HashSet<string> GetDataListByName(string dataListName);
|
||||
|
||||
public bool IsValueInList(string dataListName, string value);
|
||||
|
||||
public string GetLocalizedValue(string dataListName, string? value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Somnia.GuestLog.Resources;
|
||||
|
||||
namespace Somnia.GuestLog.Services;
|
||||
|
||||
public class StaticDataListService() : IDataListService
|
||||
public class StaticDataListService(
|
||||
IServiceProvider serviceProvider
|
||||
) : IDataListService
|
||||
{
|
||||
|
||||
private IStringLocalizer<DataListLocale> _dataListLang
|
||||
{
|
||||
get
|
||||
{
|
||||
return serviceProvider.GetRequiredService<IStringLocalizer<DataListLocale>>();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, HashSet<string>> dataListDict = new([
|
||||
new KeyValuePair<string, HashSet<string>>(GuestConsts.DataList_DocumentTypes, _documentTypeSet),
|
||||
new KeyValuePair<string, HashSet<string>>(GuestConsts.DataList_GenderOptions, _genderOptionSet),
|
||||
@@ -28,6 +42,11 @@ public class StaticDataListService() : IDataListService
|
||||
return set.Contains(value);
|
||||
}
|
||||
|
||||
public string GetLocalizedValue(string dataListName, string? value)
|
||||
{
|
||||
return _dataListLang[$"dataList.{dataListName}.{value}"];
|
||||
}
|
||||
|
||||
|
||||
#region DataList Dicts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user