public static List <string> ToList(LanguageMapList list, string languageCode) { //Fast check if (list.ContainsKey(languageCode)) { return(list[languageCode]); } //Search var parts = languageCode.ToLower().Split('-').ToList(); while (parts.Count() > 0) { var match = list.Keys.FirstOrDefault(m => m.ToLower() == string.Join("-", parts)); if (match != null) { return(list[match]); } var closeMatch = list.Keys.FirstOrDefault(m => m.ToLower().Contains(string.Join("-", parts))); if (closeMatch != null) { return(list[closeMatch]); } parts.Remove(parts.Last()); } //Default return(new List <string>()); }
public List <string> ToList(string languageCode) { return(LanguageMapList.ToList(this, languageCode)); }