Ejemplo n.º 1
0
 public CultureInfo GetPreferedCulture(IList <CultureInfo> cultures)
 {
     if (cultures == null)
     {
         throw new ArgumentNullException("cultures");
     }
     for (int i = 0; i < cultures.Count; i++)
     {
         bool flag;
         if (!this.resourceAvailabilityMap.TryGetValue(cultures[i].LCID, out flag))
         {
             CultureInfo cultureInfo = cultures[i];
             if (ClientLanguageConstraint.IsSupportedCulture(cultureInfo))
             {
                 ResourceSet resourceSet = this.resourceManager.GetResourceSet(cultureInfo, true, false);
                 while (resourceSet == null && cultureInfo.Parent != CultureInfo.InvariantCulture)
                 {
                     cultureInfo = cultureInfo.Parent;
                     resourceSet = this.resourceManager.GetResourceSet(cultureInfo, true, false);
                 }
                 if (resourceSet != null)
                 {
                     flag = true;
                 }
             }
             this.AddCultureMapping(cultures[i], flag);
         }
         if (flag || Util.PreferedCultureSelector.TestHookAllResourcesExist)
         {
             CultureInfo cultureInfo2 = cultures[i];
             if (cultureInfo2.IsNeutralCulture)
             {
                 try
                 {
                     cultureInfo2 = CultureInfo.CreateSpecificCulture(cultureInfo2.Name);
                 }
                 catch (ArgumentException)
                 {
                     goto IL_BC;
                 }
             }
             return(cultureInfo2);
         }
         IL_BC :;
     }
     return(CultureInfo.CurrentCulture);
 }
Ejemplo n.º 2
0
        public static CultureInfo GetSupportedUserCulture(ADUser adUser)
        {
            if (adUser == null)
            {
                throw new ArgumentNullException("adUser");
            }
            CultureInfo result = null;

            if (adUser.Languages != null)
            {
                foreach (CultureInfo cultureInfo in adUser.Languages)
                {
                    if (ClientLanguageConstraint.IsSupportedCulture(cultureInfo))
                    {
                        result = cultureInfo;
                        break;
                    }
                }
            }
            return(result);
        }