ClientCultureInfo.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / Orcas / RTM / ndp / fx / src / xsp / System / Web / Extensions / Globalization / ClientCultureInfo.cs / 1 / ClientCultureInfo.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.Globalization { 
    using System; 
    using System.Collections;
    using System.Globalization; 
    using System.Text;
    using System.Web.Script.Serialization;

    internal class ClientCultureInfo { 

        private static Hashtable cultureScriptBlockCache = Hashtable.Synchronized(new Hashtable()); 
        private static readonly CultureInfo enUS = CultureInfo.GetCultureInfo(0x409); 

        public string name; 
        public NumberFormatInfo numberFormat;
        public DateTimeFormatInfo dateTimeFormat;

        private ClientCultureInfo(CultureInfo cultureInfo) { 
            name = cultureInfo.Name;
            numberFormat = cultureInfo.NumberFormat; 
            dateTimeFormat = cultureInfo.DateTimeFormat; 
        }
 
        internal static string GetClientCultureScriptBlock() {
            return GetClientCultureScriptBlock(CultureInfo.CurrentCulture);
        }
 
        internal static string GetClientCultureScriptBlock(CultureInfo cultureInfo) {
            if ((cultureInfo == null) || cultureInfo.Equals(enUS)) { 
                return null; 
            }
 
            object cached = cultureScriptBlockCache[cultureInfo];
            if (cached == null) {
                ClientCultureInfo clientCultureInfo = new ClientCultureInfo(cultureInfo);
                string rawJsonString = JavaScriptSerializer.SerializeInternal(clientCultureInfo); 
                if (rawJsonString.Length > 0) {
                    cached = "var __cultureInfo = '" + rawJsonString + "';"; 
                } 
                cultureScriptBlockCache[cultureInfo] = cached;
            } 
            return (string)cached;
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK