v1.1.7.1
This commit is contained in:
@@ -41,30 +41,39 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key)
|
||||
{
|
||||
return GetText(key, new object[] { });
|
||||
return GetText(key, null);
|
||||
}
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key, bool logMissingKey = true)
|
||||
{
|
||||
return GetText(key, null, logMissingKey);
|
||||
}
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key, object param)
|
||||
{
|
||||
return GetText(key, new object[] { param });
|
||||
}
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key, object param1, object param2)
|
||||
{
|
||||
return GetText(key, new object[] { param1, param2 });
|
||||
}
|
||||
public LocalizedString GetText(string key, object[] parameters)
|
||||
/// <summary>Retrieve localised text.</summary>
|
||||
public LocalizedString GetText(string key, object[] parameters, bool logMissingKey = true)
|
||||
{
|
||||
LocalizedString text = MainProperties.GetString(key, parameters);
|
||||
LocalizedString text = parameters == null || parameters.IsEmpty() ? MainProperties.GetString(key) : MainProperties.GetString(key, parameters);
|
||||
if (text.ResourceNotFound)
|
||||
{
|
||||
SaLogger.Debug(GetType().Name + ".GetText Key not found: " + key);
|
||||
// Look up key in alternative property files.
|
||||
foreach (IStringLocalizer properties in AlternativeProperties ?? new List<IStringLocalizer>())
|
||||
{
|
||||
text = properties.GetString(key, parameters);
|
||||
text = parameters == null || parameters.IsEmpty() ? properties.GetString(key) : properties.GetString(key, parameters);
|
||||
if (!text.ResourceNotFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (text.ResourceNotFound && logMissingKey)
|
||||
SaLogger.Debug(GetType().Name + ".GetText Key not found: " + key);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -135,19 +144,21 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
// Specific phrase translation.
|
||||
//-------------------------------------------------------------------
|
||||
private class CodeCache
|
||||
private class CodesCache
|
||||
{
|
||||
public List<TypeCodeDesc> genderCodes;
|
||||
public List<TypeCodeDesc> sportParticipationCodes;
|
||||
public List<TypeCodeDesc> sportOfficiatingCodes;
|
||||
public List<TypeCodeDesc> regionTypeCodes;
|
||||
public List<TypeCodeDesc> userRoleCodes;
|
||||
public List<TypeCodeDesc> organisationTypeCodes;
|
||||
public List<TypeCodeDesc> organisationCategoryCodes;
|
||||
public List<TypeCodeDesc> organisationRoleCodes;
|
||||
public List<TypeCodeDesc> opportunityTypeCodes;
|
||||
private Dictionary<Sax.CodeType, List<TypeCodeDesc>> codeTypeCache { get; } = new Dictionary<Sax.CodeType, List<TypeCodeDesc>>();
|
||||
public List<TypeCodeDesc> GetCodesOfType(Sax.CodeType codeType)
|
||||
{
|
||||
List<TypeCodeDesc> codes = codeTypeCache.GetValue(codeType, null);
|
||||
if (codes == null)
|
||||
{
|
||||
codes = SaxSystem.GetCodesOfType(codeType);
|
||||
codeTypeCache.Add(codeType, codes);
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
}
|
||||
private CodeCache codes = new CodeCache();
|
||||
private CodesCache codesCache = new CodesCache();
|
||||
|
||||
// Status.
|
||||
public String GetStatusCaption(SaStatus status)
|
||||
@@ -156,94 +167,100 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
return SacsSystem.GetStatusDesc(status);
|
||||
}
|
||||
|
||||
// Generic code type.
|
||||
private String GetCodeTypeCaption<T>(Sax.CodeType codeType, T type) where T : struct, IConvertible
|
||||
{
|
||||
if (!(type is Enum))
|
||||
throw new ArgumentException(GetType().Name + ".GetCodeTypeCaption Type parameter must be an enumerated type. Type supplied: " + type.GetType().Name);
|
||||
return GetCodeTypeCaption(codeType, (int)(type as IConvertible), type.ToString());
|
||||
}
|
||||
private String GetCodeTypeCaption(Sax.CodeType codeType, int type, String typeName)
|
||||
{
|
||||
if (type < 1) return "";
|
||||
List<TypeCodeDesc> codes = this.codesCache.GetCodesOfType(codeType);
|
||||
TypeCodeDesc code = codes.GetEntryForType(type);
|
||||
if (code != null)
|
||||
{
|
||||
// Code Type localisation.
|
||||
String codeTypeKey = "codeType." + codeType.ToString() + "." + typeName;
|
||||
String typeDesc = GetText(codeTypeKey, false);
|
||||
if (typeDesc.EqualsCI(codeTypeKey))
|
||||
typeDesc = "";
|
||||
return StringUtil.OnEmpty(typeDesc, code.Desc);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Yes/No.
|
||||
public String GetYesNoCaption(Sax.YesNo yesNo)
|
||||
{
|
||||
return GetCodeTypeCaption(Sax.CodeType.YesNo, yesNo);
|
||||
}
|
||||
|
||||
// Data item type.
|
||||
public String GetItemDataTypeCaption(Sax.DataItemType itemType)
|
||||
{
|
||||
return GetCodeTypeCaption(Sax.CodeType.DataItemType, itemType);
|
||||
}
|
||||
|
||||
// Gender.
|
||||
public String GetGenderCaption(Sax.Gender gender)
|
||||
{
|
||||
if ((int)gender < 1) return "";
|
||||
if (codes.genderCodes == null)
|
||||
codes.genderCodes = SaxSystem.GetCodesOfType(Sax.CodeType.Gender);
|
||||
// ToDo Opportunity Type localisation.
|
||||
return codes.genderCodes.GetDescForType(gender);
|
||||
return GetCodeTypeCaption(Sax.CodeType.Gender, gender);
|
||||
}
|
||||
|
||||
// Sport Speciality label.
|
||||
public String GetSportSpecialityLabelCaption(Sax.SportSpecialityLabel specialityLabel)
|
||||
{
|
||||
return GetCodeTypeCaption(Sax.CodeType.SportSpecialityLabel, specialityLabel);
|
||||
}
|
||||
|
||||
// Sport Participation.
|
||||
public String GetSportParticipationTypeCaption(Sax.SportParticipation participation)
|
||||
public String GetSportParticipationCaption(Sax.SportParticipation participation)
|
||||
{
|
||||
if ((int)participation < 1) return "";
|
||||
if (codes.sportParticipationCodes == null)
|
||||
codes.sportParticipationCodes = SaxSystem.GetCodesOfType(Sax.CodeType.SportParticipation);
|
||||
// ToDo Sport Participation localisation.
|
||||
return codes.sportParticipationCodes.GetDescForType(participation);
|
||||
return GetCodeTypeCaption(Sax.CodeType.SportParticipation, participation);
|
||||
}
|
||||
|
||||
// Sport Officiating.
|
||||
public String GetSportOfficiatingTypeCaption(Sax.SportOfficiating participation)
|
||||
public String GetSportOfficiatingCaption(Sax.SportOfficiating participation)
|
||||
{
|
||||
if ((int)participation < 1) return "";
|
||||
if (codes.sportOfficiatingCodes == null)
|
||||
codes.sportOfficiatingCodes = SaxSystem.GetCodesOfType(Sax.CodeType.SportOfficiating);
|
||||
// ToDo Sport Officiating localisation.
|
||||
return codes.sportOfficiatingCodes.GetDescForType(participation);
|
||||
return GetCodeTypeCaption(Sax.CodeType.SportOfficiating, participation);
|
||||
}
|
||||
|
||||
// Region type.
|
||||
public String GetRegionTypeCaption(Sax.RegionType regionType)
|
||||
{
|
||||
if ((int)regionType < 1) return "";
|
||||
if (codes.regionTypeCodes == null)
|
||||
codes.regionTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.RegionType);
|
||||
// ToDo Region type localisation.
|
||||
return codes.regionTypeCodes.GetDescForType(regionType);
|
||||
return GetCodeTypeCaption(Sax.CodeType.RegionType, regionType);
|
||||
}
|
||||
|
||||
// User role.
|
||||
public String GetUserRoleCaption(Sax.UserRole userRole)
|
||||
{
|
||||
if ((int)userRole < 1) return "";
|
||||
if (codes.userRoleCodes == null)
|
||||
codes.userRoleCodes = SaxSystem.GetCodesOfType(Sax.CodeType.UserRole);
|
||||
// ToDo User Role localisation.
|
||||
return codes.userRoleCodes.GetDescForType(userRole);
|
||||
return GetCodeTypeCaption(Sax.CodeType.UserRole, userRole);
|
||||
}
|
||||
|
||||
// Organisation type.
|
||||
public String GetOrganisationTypeCaption(Sax.OrganisationType organisationType)
|
||||
{
|
||||
if ((int)organisationType < 1) return "";
|
||||
if (codes.organisationTypeCodes == null)
|
||||
codes.organisationTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationType);
|
||||
// ToDo Organisation Type localisation.
|
||||
return codes.organisationTypeCodes.GetDescForType(organisationType);
|
||||
return GetCodeTypeCaption(Sax.CodeType.OrganisationType, organisationType);
|
||||
}
|
||||
|
||||
// Organisation category.
|
||||
public String GetOrganisationCategoryCaption(Sax.OrganisationCategory organisationCategory)
|
||||
{
|
||||
if ((int)organisationCategory < 1) return "";
|
||||
if (codes.organisationCategoryCodes == null)
|
||||
codes.organisationCategoryCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationCategory);
|
||||
// ToDo Organisation Category localisation.
|
||||
return codes.organisationCategoryCodes.GetDescForType(organisationCategory);
|
||||
return GetCodeTypeCaption(Sax.CodeType.OrganisationCategory, organisationCategory);
|
||||
}
|
||||
|
||||
// Organisation role.
|
||||
public String GetOrganisationRoleCaption(Sax.OrganisationRole organisationRole)
|
||||
{
|
||||
if ((int)organisationRole < 1) return "";
|
||||
if (codes.organisationRoleCodes == null)
|
||||
codes.organisationRoleCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OrganisationRole);
|
||||
// ToDo Organisation Role localisation.
|
||||
return codes.organisationRoleCodes.GetDescForType(organisationRole);
|
||||
return GetCodeTypeCaption(Sax.CodeType.OrganisationRole, organisationRole);
|
||||
}
|
||||
|
||||
// Opportunity type.
|
||||
public String GetOpportunityTypeCaption(Sax.OpportunityType opportunityType)
|
||||
{
|
||||
if ((int)opportunityType < 1) return "";
|
||||
if (codes.opportunityTypeCodes == null)
|
||||
codes.opportunityTypeCodes = SaxSystem.GetCodesOfType(Sax.CodeType.OpportunityType);
|
||||
// ToDo Opportunity Type localisation.
|
||||
return codes.opportunityTypeCodes.GetDescForType(opportunityType);
|
||||
return GetCodeTypeCaption(Sax.CodeType.OpportunityType, opportunityType);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -288,8 +288,8 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc yesNo in SaxSystem.GetCodesOfType(Sax.CodeType.YesNo))
|
||||
values.Add(new SelectListItem(yesNo.Code, GetYesNoCaption((Sax.YesNo)yesNo.Type)));
|
||||
foreach (TypeCodeDesc yesNo in YesNoCodes)
|
||||
values.Add(new SelectListItem(yesNo.Code, Localiser.GetYesNoCaption((Sax.YesNo)yesNo.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
@@ -299,29 +299,48 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SelectListItem> codes = new List<SelectListItem>();
|
||||
codes.Add(new SelectListItem("Default", ""));
|
||||
codes.AddRange(new SelectList(SportSpecialityLabelCodes, "Code", "Desc"));
|
||||
return codes;
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
values.Add(new SelectListItem("Default", ""));
|
||||
foreach (TypeCodeDesc sportSpecialityLabel in SportSpecialityLabelCodes)
|
||||
values.Add(new SelectListItem(sportSpecialityLabel.Code, Localiser.GetSportSpecialityLabelCaption((Sax.SportSpecialityLabel)sportSpecialityLabel.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of Sport Participation options for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> SportParticipationCodesForSelect
|
||||
{
|
||||
get { return new SelectList(SportParticipationCodes, "Code", "Desc"); }
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc sportParticipation in SportParticipationCodes)
|
||||
values.Add(new SelectListItem(sportParticipation.Code, Localiser.GetSportParticipationCaption((Sax.SportParticipation)sportParticipation.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of Sport Officiating options for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> SportOfficiatingCodesForSelect
|
||||
{
|
||||
get { return new SelectList(SportOfficiatingCodes, "Code", "Desc"); }
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc sportOfficiating in SportOfficiatingCodes)
|
||||
values.Add(new SelectListItem(sportOfficiating.Code, Localiser.GetSportOfficiatingCaption((Sax.SportOfficiating)sportOfficiating.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of Region Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> RegionTypesForSelect
|
||||
{
|
||||
get { return new SelectList(RegionTypeCodes.FindAll(item => item.Type != (int)Sax.RegionType.Universe && item.Type != (int)Sax.RegionType.Galaxy), "Code", "Desc"); }
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc organisationType in RegionTypeCodes.FindAll(item => item.Type != (int)Sax.RegionType.Universe && item.Type != (int)Sax.RegionType.Galaxy))
|
||||
values.Add(new SelectListItem(organisationType.Code, Localiser.GetRegionTypeCaption((Sax.RegionType)organisationType.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of titles for dropdown.</summary>
|
||||
@@ -333,27 +352,25 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
/// <summary>List of Organisation Types for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> OrganisationTypesForSelect
|
||||
{
|
||||
get { return new SelectList(OrganisationTypeCodes, "Code", "Desc"); }
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc organisationType in OrganisationTypeCodes)
|
||||
values.Add(new SelectListItem(organisationType.Code, Localiser.GetOrganisationTypeCaption((Sax.OrganisationType)organisationType.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>List of Organisation Categories for dropdown.</summary>
|
||||
public IEnumerable<SelectListItem> OrganisationCategoriesForSelect
|
||||
{
|
||||
get { return new SelectList(OrganisationCategoryCodes, "Code", "Desc"); }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Localisation.
|
||||
//-------------------------------------------------------------------
|
||||
public String GetItemDataTypeCaption(Sax.DataItemType itemType)
|
||||
{
|
||||
// Default - return code description.
|
||||
return DataItemTypeCodes.GetDescForType(itemType);
|
||||
}
|
||||
public String GetYesNoCaption(Sax.YesNo yesNo)
|
||||
{
|
||||
// Default - return code description.
|
||||
return YesNoCodes.GetDescForType(yesNo);
|
||||
get
|
||||
{
|
||||
List<SelectListItem> values = new List<SelectListItem>();
|
||||
foreach (TypeCodeDesc organisationCategory in OrganisationCategoryCodes)
|
||||
values.Add(new SelectListItem(organisationCategory.Code, Localiser.GetOrganisationCategoryCaption((Sax.OrganisationCategory)organisationCategory.Type)));
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user