Exemple #1
0
        /// <summary>Returns the <see cref="T:System.Globalization.CultureInfo" /> for the main assembly's neutral resources by reading the value of the <see cref="T:System.Resources.NeutralResourcesLanguageAttribute" /> on a specified <see cref="T:System.Reflection.Assembly" />.</summary>
        /// <returns>The culture from the <see cref="T:System.Resources.NeutralResourcesLanguageAttribute" />, if found; otherwise, <see cref="P:System.Globalization.CultureInfo.InvariantCulture" />.</returns>
        /// <param name="a">The assembly for which to return a <see cref="T:System.Globalization.CultureInfo" />. </param>
        protected static CultureInfo GetNeutralResourcesLanguage(Assembly a)
        {
            object[] customAttributes = a.GetCustomAttributes(typeof(NeutralResourcesLanguageAttribute), false);
            if (customAttributes.Length == 0)
            {
                return(CultureInfo.InvariantCulture);
            }
            NeutralResourcesLanguageAttribute neutralResourcesLanguageAttribute = (NeutralResourcesLanguageAttribute)customAttributes[0];

            return(new CultureInfo(neutralResourcesLanguageAttribute.CultureName));
        }
Exemple #2
0
        protected static CultureInfo GetNeutralResourcesLanguage(Assembly a)
        {
            object [] attrs = a.GetCustomAttributes(
                typeof(NeutralResourcesLanguageAttribute),
                false);

            if (attrs.Length == 0)
            {
                return(CultureInfo.InvariantCulture);
            }
            else
            {
                NeutralResourcesLanguageAttribute res_attr = (NeutralResourcesLanguageAttribute)attrs [0];
                return(new CultureInfo(res_attr.CultureName));
            }
        }