protected bool GetResource(out T resource, string context, string message = null, LanguageGender gender = LanguageGender.Neutral, int pluralCount = 1) { var cached_string = new CachedString { Message = message, Gender = gender, PluralOrder = PluralRules.GetOrder(CurrentIsoLanguageCode, pluralCount) }; if (string_cache.TryGetValue(cached_string, out resource)) { return(true); } var id = GetResourceId(ResourceIdType.ComprehensibleIdentifier, context, message, gender, cached_string.PluralOrder); var field = reflection_type.GetTypeInfo().GetDeclaredField(id); if (field == null) { if (gender != LanguageGender.Neutral) { return(GetResource(out resource, context, message, LanguageGender.Neutral, pluralCount)); } return(false); } resource = (T)field.GetValue(null); string_cache.Add(cached_string, resource); return(true); }
protected virtual string GetResource(string context, string message, LanguageGender gender = LanguageGender.Neutral, int pluralCount = 1) { if (GetResourceById == null) { return(null); } var plural_order = PluralRules.GetOrder(CurrentIsoLanguageCode, pluralCount); var resource_id = GetResourceId(ResourceIdType, context, message, gender, plural_order); if (resource_id == null) { return(null); } return(GetResourceById(resource_id)); }