Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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. // //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ScrollViewerAutomationPeer.cs
- SemanticResultKey.cs
- CacheRequest.cs
- GridPattern.cs
- MetafileHeaderWmf.cs
- DesignConnectionCollection.cs
- MetadataImporterQuotas.cs
- Matrix.cs
- CompilerResults.cs
- XPathEmptyIterator.cs
- DefaultClaimSet.cs
- XmlSequenceWriter.cs
- CurrentChangingEventArgs.cs
- QilFactory.cs
- documentsequencetextcontainer.cs
- TextEditorDragDrop.cs
- BypassElement.cs
- RepeaterItem.cs
- PlatformNotSupportedException.cs
- ProxyWebPartManager.cs
- MsmqChannelListenerBase.cs
- CallSite.cs
- RankException.cs
- PrintEvent.cs
- JsonByteArrayDataContract.cs
- ParseChildrenAsPropertiesAttribute.cs
- ExternalException.cs
- TablePatternIdentifiers.cs
- TdsParserSafeHandles.cs
- X509Certificate.cs
- FilterElement.cs
- EventSetter.cs
- ObjectConverter.cs
- SourceInterpreter.cs
- WebPartVerbCollection.cs
- ProxyHwnd.cs
- EventProxy.cs
- FusionWrap.cs
- ToolbarAUtomationPeer.cs
- MenuCommandsChangedEventArgs.cs
- VirtualPath.cs
- NativeMethods.cs
- ResourceSet.cs
- UIAgentCrashedException.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- Content.cs
- AllMembershipCondition.cs
- FileUtil.cs
- OracleDataReader.cs
- BitmapEffectDrawingContextWalker.cs
- SqlUdtInfo.cs
- DataKey.cs
- WebException.cs
- RectValueSerializer.cs
- WebEncodingValidatorAttribute.cs
- KernelTypeValidation.cs
- Overlapped.cs
- XamlStream.cs
- WorkflowQueuingService.cs
- BrowserTree.cs
- DispatcherBuilder.cs
- EntitySqlQueryCacheEntry.cs
- BaseUriHelper.cs
- FeatureSupport.cs
- UserNamePasswordServiceCredential.cs
- SetIndexBinder.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- SafeThreadHandle.cs
- ZipIOFileItemStream.cs
- BindingMAnagerBase.cs
- ChannelEndpointElement.cs
- DataGridCommandEventArgs.cs
- ErasingStroke.cs
- ContainerUtilities.cs
- TextTreeUndo.cs
- ImageIndexConverter.cs
- WebControlAdapter.cs
- SweepDirectionValidation.cs
- PaintValueEventArgs.cs
- DependencyProperty.cs
- CodeConditionStatement.cs
- EnterpriseServicesHelper.cs
- HandleValueEditor.cs
- Shape.cs
- Label.cs
- DirectoryObjectSecurity.cs
- TreePrinter.cs
- SspiHelper.cs
- Relationship.cs
- TextDecorationCollection.cs
- QilReplaceVisitor.cs
- RemoteHelper.cs
- QilCloneVisitor.cs
- HtmlGenericControl.cs
- EnumBuilder.cs
- AttributeSetAction.cs
- UnsettableComboBox.cs
- LookupNode.cs
- XmlValueConverter.cs
- EventSinkActivityDesigner.cs