private void ParsePresentedLanguagesSection(XElement presentedLanguagesSection)
        {
            ElementNameToLanguageMap = presentedLanguagesSection
                                       .LanguageSections()
                                       .Select(
                languageSection =>
            {
                // ReSharper disable PossibleNullReferenceException
                var languageName = languageSection.Attribute("Name").Value;
                // ReSharper restore PossibleNullReferenceException
                var nodeName = languageSection.Attribute("NodeName").Value();

                return(new
                {
                    LanguageName = languageName,
                    NodeName = nodeName ?? languageName
                });
            }
                )
                                       .Where(
                languageNodeData => AllowedLanguages == null || AllowedLanguages.Contains(languageNodeData.LanguageName)
                )
                                       .ToDictionary(
                x => x.NodeName,
                x => x.LanguageName
                );


            PresentedLanguages = ElementNameToLanguageMap.Select(x => x.Value).ToList();
        }
Esempio n. 2
0
 /// <summary>
 /// Try and set the specified language, first verifying that we have it loaded and it is allowed to select it.
 /// </summary>
 /// <param name="newDefaultLanguage"></param>
 /// <returns></returns>
 public static bool TrySetAllowedLanguage(string newDefaultLanguage)
 {
     if (AllowedLanguages.Contains(newDefaultLanguage) && Languages.Contains(newDefaultLanguage))
     {
         Language = newDefaultLanguage;
         return(true);
     }
     return(false);
 }
        private void ParseDefaultLanguageSection(XElement defaultLanguageSection)
        {
            var defaultLanguage = defaultLanguageSection.Value();

            if (AllowedLanguages == null || AllowedLanguages.Contains(defaultLanguage))
            {
                DefaultLanguage = defaultLanguage;
            }
        }