public string[] GetValue(CodeGroupType groupType, string language, string code) { if (!CodeGroups.Any()) { return(null); } if (string.IsNullOrEmpty(language)) { return(null); } if (string.IsNullOrEmpty(code)) { return(null); } var codeGroup = CodeGroups.FirstOrDefault(cg => cg.Type == groupType && cg.Translations.Any(t => t.Language.Equals(language, StringComparison.OrdinalIgnoreCase))); if (codeGroup == null) { return(null); } var translations = codeGroup.Translations.Where(t => t.Language.Equals(language, StringComparison.OrdinalIgnoreCase)); return(translations.Select(t => t.Value).ToArray()); }
public CodeGroup(CodeGroupType type, string code, string value) { _type = type; _code = code; _translations.Add(new CodeGroupTranslation(culture: CurrentCulture, language: CurrentLanguage, value: value)); }
public string GetValue(CodeGroupType groupType, string culture, string language, string code) { if (!CodeGroups.Any()) { return(null); } if (string.IsNullOrEmpty(culture)) { return(null); } if (string.IsNullOrEmpty(language)) { return(null); } if (string.IsNullOrEmpty(code)) { return(null); } var codeGroup = CodeGroups.FirstOrDefault(cg => cg.Type == groupType && cg.Translations.Any(t => t.Culture.Equals(culture, StringComparison.OrdinalIgnoreCase) && t.Language.Equals(language, StringComparison.OrdinalIgnoreCase))); if (codeGroup == null) { return(null); } var translation = codeGroup.Translations.FirstOrDefault(t => t.Culture.Equals(culture, StringComparison.OrdinalIgnoreCase) && t.Language.Equals(language, StringComparison.OrdinalIgnoreCase)); return(translation != null ? translation.Value : null); }
public ObservableCollection <CodeGroup> GetCodeGroups(CodeGroupType type) { var codeGroups = new ObservableCollection <CodeGroup>(); if (!CodeGroups.Any()) { return(codeGroups); } return(CodeGroups.Where(cg => cg.Type == type) .ToObservableCollection()); }
public CodeGroup(CodeGroupType type, string code, IEnumerable <CodeGroupTranslation> translations) { _type = type; _code = code; if (translations == null || !translations.Any()) { return; } foreach (var translation in translations) { _translations.Add(translation); } }
public string GetValue(CodeGroupType groupType, string code) { if (!CodeGroups.Any()) { return(null); } if (string.IsNullOrEmpty(code)) { return(null); } var codeGroup = CodeGroups.FirstOrDefault(cg => cg.Type == groupType && cg.Code.Equals(code, StringComparison.OrdinalIgnoreCase)); return(codeGroup != null ? codeGroup.Value : null); }
public string GetCode(CodeGroupType groupType, string value) { if (!CodeGroups.Any()) { return(null); } if (string.IsNullOrEmpty(value)) { return(null); } var codeGroup = CodeGroups.FirstOrDefault(cg => cg.Type == groupType && cg.Translations.Any(t => t.Value != null && t.Value.Contains(value))); return(codeGroup != null ? codeGroup.Code : null); }
public CodeGroup(string name, string code, IEnumerable <CodeGroupTranslation> translations) { CodeGroupType type; if (Enum.TryParse(name, true, out type)) { _type = type; _code = code; if (translations == null || !translations.Any()) { return; } foreach (var translation in translations) { _translations.Add(translation); } return; } throw new InvalidCastException("No enumeration defined for" + name); }