insert_into_shared_tables() static private method

static private insert_into_shared_tables ( CultureInfo c ) : void
c CultureInfo
return void
Beispiel #1
0
        /// <summary>Retrieves a cached, read-only instance of a culture using the specified culture name. </summary>
        /// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
        /// <param name="name">The name of a culture.</param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="name" /> is null.</exception>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="name" /> specifies a culture that is not supported.</exception>
        public static CultureInfo GetCultureInfo(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            object      obj = CultureInfo.shared_table_lock;
            CultureInfo result;

            lock (obj)
            {
                CultureInfo cultureInfo;
                if (CultureInfo.shared_by_name != null)
                {
                    cultureInfo = (CultureInfo.shared_by_name[name] as CultureInfo);
                    if (cultureInfo != null)
                    {
                        return(cultureInfo);
                    }
                }
                cultureInfo = new CultureInfo(name, false, true);
                CultureInfo.insert_into_shared_tables(cultureInfo);
                result = cultureInfo;
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>Retrieves a cached, read-only instance of a culture using the specified culture identifier.</summary>
        /// <returns>A read-only <see cref="T:System.Globalization.CultureInfo" /> object.</returns>
        /// <param name="culture">A culture identifier.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="culture" /> is less than zero.</exception>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="culture" /> specifies a culture that is not supported.</exception>
        public static CultureInfo GetCultureInfo(int culture)
        {
            object      obj = CultureInfo.shared_table_lock;
            CultureInfo result;

            lock (obj)
            {
                CultureInfo cultureInfo;
                if (CultureInfo.shared_by_number != null)
                {
                    cultureInfo = (CultureInfo.shared_by_number[culture] as CultureInfo);
                    if (cultureInfo != null)
                    {
                        return(cultureInfo);
                    }
                }
                cultureInfo = new CultureInfo(culture, false, true);
                CultureInfo.insert_into_shared_tables(cultureInfo);
                result = cultureInfo;
            }
            return(result);
        }