Esempio n. 1
0
        /// <summary>Creates a <see cref="T:System.Globalization.CultureInfo" /> object that represents the specific culture that is associated with the specified name.</summary>
        /// <returns>A <see cref="T:System.Globalization.CultureInfo" /> object that represents:The invariant culture, if <paramref name="name" /> is an empty string ("").-or- The specific culture associated with <paramref name="name" />, if <paramref name="name" /> is a neutral culture.-or- The culture specified by <paramref name="name" />, if <paramref name="name" /> is already a specific culture.</returns>
        /// <param name="name">A predefined <see cref="T:System.Globalization.CultureInfo" /> name or the name of an existing <see cref="T:System.Globalization.CultureInfo" /> object. </param>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="name" /> is not a valid culture name.-or- The culture specified by <paramref name="name" /> does not have a specific culture associated with it. </exception>
        /// <exception cref="T:System.NullReferenceException">
        ///   <paramref name="name" /> is null. </exception>
        public static CultureInfo CreateSpecificCulture(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name == string.Empty)
            {
                return(CultureInfo.InvariantCulture);
            }
            CultureInfo cultureInfo = new CultureInfo();

            if (!CultureInfo.ConstructInternalLocaleFromSpecificName(cultureInfo, name.ToLowerInvariant()))
            {
                throw new ArgumentException("Culture name " + name + " is not supported.", name);
            }
            return(cultureInfo);
        }