Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / Configuration / ScriptingJsonSerializationSection.cs / 1305376 / ScriptingJsonSerializationSection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Configuration; using System.Web; using System.Web.Configuration; using System.Web.Script.Serialization; public sealed class ScriptingJsonSerializationSection : ConfigurationSection { private static readonly ConfigurationProperty _propConverters = new ConfigurationProperty("converters", typeof(ConvertersCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); private static readonly ConfigurationProperty _propRecursionLimitLimit = new ConfigurationProperty("recursionLimit", typeof(int), 100, null, new IntegerValidator(1, int.MaxValue), ConfigurationPropertyOptions.None); private static readonly ConfigurationProperty _propMaxJsonLength = new ConfigurationProperty("maxJsonLength", typeof(int), 102400, null, new IntegerValidator(1, int.MaxValue), ConfigurationPropertyOptions.None); private static ConfigurationPropertyCollection _properties = BuildProperties(); private static ConfigurationPropertyCollection BuildProperties() { ConfigurationPropertyCollection props = new ConfigurationPropertyCollection(); props.Add(_propConverters); props.Add(_propRecursionLimitLimit); props.Add(_propMaxJsonLength); return props; } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty("converters", IsKey = true, DefaultValue = "")] public ConvertersCollection Converters { get { return (ConvertersCollection)base[_propConverters]; } } [ConfigurationProperty("recursionLimit", DefaultValue = 100)] public int RecursionLimit { get { return (int)base[_propRecursionLimitLimit]; } set { base[_propRecursionLimitLimit] = value; } } [ConfigurationProperty("maxJsonLength", DefaultValue = 102400)] public int MaxJsonLength { get { return (int)base[_propMaxJsonLength]; } set { base[_propMaxJsonLength] = value; } } internal class ApplicationSettings { private int _recusionLimit; private int _maxJsonLimit; private JavaScriptConverter[] _converters; internal ApplicationSettings() { #pragma warning disable 0436 ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection) WebConfigurationManager.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); #pragma warning restore 0436 if (section != null) { _recusionLimit = section.RecursionLimit; _maxJsonLimit = section.MaxJsonLength; _converters = section.Converters.CreateConverters(); } else { _recusionLimit = (int)_propRecursionLimitLimit.DefaultValue; _maxJsonLimit = (int)_propMaxJsonLength.DefaultValue; _converters = new JavaScriptConverter[0]; } } internal int RecursionLimit { get { return _recusionLimit; } } internal int MaxJsonLimit { get { return _maxJsonLimit; } } internal JavaScriptConverter[] Converters { get { return _converters; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Configuration; using System.Web; using System.Web.Configuration; using System.Web.Script.Serialization; public sealed class ScriptingJsonSerializationSection : ConfigurationSection { private static readonly ConfigurationProperty _propConverters = new ConfigurationProperty("converters", typeof(ConvertersCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); private static readonly ConfigurationProperty _propRecursionLimitLimit = new ConfigurationProperty("recursionLimit", typeof(int), 100, null, new IntegerValidator(1, int.MaxValue), ConfigurationPropertyOptions.None); private static readonly ConfigurationProperty _propMaxJsonLength = new ConfigurationProperty("maxJsonLength", typeof(int), 102400, null, new IntegerValidator(1, int.MaxValue), ConfigurationPropertyOptions.None); private static ConfigurationPropertyCollection _properties = BuildProperties(); private static ConfigurationPropertyCollection BuildProperties() { ConfigurationPropertyCollection props = new ConfigurationPropertyCollection(); props.Add(_propConverters); props.Add(_propRecursionLimitLimit); props.Add(_propMaxJsonLength); return props; } protected override ConfigurationPropertyCollection Properties { get { return _properties; } } [ConfigurationProperty("converters", IsKey = true, DefaultValue = "")] public ConvertersCollection Converters { get { return (ConvertersCollection)base[_propConverters]; } } [ConfigurationProperty("recursionLimit", DefaultValue = 100)] public int RecursionLimit { get { return (int)base[_propRecursionLimitLimit]; } set { base[_propRecursionLimitLimit] = value; } } [ConfigurationProperty("maxJsonLength", DefaultValue = 102400)] public int MaxJsonLength { get { return (int)base[_propMaxJsonLength]; } set { base[_propMaxJsonLength] = value; } } internal class ApplicationSettings { private int _recusionLimit; private int _maxJsonLimit; private JavaScriptConverter[] _converters; internal ApplicationSettings() { #pragma warning disable 0436 ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection) WebConfigurationManager.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); #pragma warning restore 0436 if (section != null) { _recusionLimit = section.RecursionLimit; _maxJsonLimit = section.MaxJsonLength; _converters = section.Converters.CreateConverters(); } else { _recusionLimit = (int)_propRecursionLimitLimit.DefaultValue; _maxJsonLimit = (int)_propMaxJsonLength.DefaultValue; _converters = new JavaScriptConverter[0]; } } internal int RecursionLimit { get { return _recusionLimit; } } internal int MaxJsonLimit { get { return _maxJsonLimit; } } internal JavaScriptConverter[] Converters { get { return _converters; } } } } } // 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
- QilExpression.cs
- RC2CryptoServiceProvider.cs
- ReachPrintTicketSerializer.cs
- LogArchiveSnapshot.cs
- ProtocolViolationException.cs
- DataListItemCollection.cs
- WsdlInspector.cs
- URLMembershipCondition.cs
- DependencyPropertyAttribute.cs
- KnownColorTable.cs
- FileDialogCustomPlace.cs
- InternalPermissions.cs
- QilLoop.cs
- Variable.cs
- MenuItemStyleCollection.cs
- RawTextInputReport.cs
- Menu.cs
- CommonObjectSecurity.cs
- AbsoluteQuery.cs
- __ConsoleStream.cs
- SHA512Managed.cs
- EventBindingService.cs
- ByteStorage.cs
- ImportedPolicyConversionContext.cs
- TrustSection.cs
- CodeIterationStatement.cs
- Span.cs
- LabelAutomationPeer.cs
- BoundField.cs
- PartitionResolver.cs
- PenThreadWorker.cs
- DbDataReader.cs
- BufferedGraphics.cs
- _FixedSizeReader.cs
- GridViewDeletedEventArgs.cs
- CardSpaceException.cs
- InlineObject.cs
- RootBrowserWindowProxy.cs
- Cursors.cs
- TreeNodeCollection.cs
- XmlSchemaElement.cs
- Calendar.cs
- LineServicesCallbacks.cs
- GridViewRow.cs
- OrderedParallelQuery.cs
- BaseTemplateCodeDomTreeGenerator.cs
- XmlDocumentSchema.cs
- TextServicesPropertyRanges.cs
- StructuredType.cs
- HostingEnvironment.cs
- RuleSet.cs
- SvcMapFileLoader.cs
- ValidationError.cs
- WindowsStatic.cs
- TrackingProfile.cs
- DrawingVisual.cs
- RadioButton.cs
- TiffBitmapEncoder.cs
- PackageRelationship.cs
- DWriteFactory.cs
- SmtpFailedRecipientsException.cs
- DataControlPagerLinkButton.cs
- AccessorTable.cs
- ByteAnimationBase.cs
- HtmlTableRow.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- Method.cs
- TdsRecordBufferSetter.cs
- SHA512.cs
- AdapterUtil.cs
- VoiceObjectToken.cs
- OdbcConnection.cs
- PriorityRange.cs
- AstTree.cs
- EmptyElement.cs
- ControlCollection.cs
- SecurityRuntime.cs
- RowBinding.cs
- MissingSatelliteAssemblyException.cs
- CharacterHit.cs
- RightsManagementEncryptionTransform.cs
- ToolStripMenuItem.cs
- MatcherBuilder.cs
- ExceptionList.cs
- GACMembershipCondition.cs
- HtmlInputText.cs
- CheckBoxFlatAdapter.cs
- ReferencedType.cs
- TextBox.cs
- _DisconnectOverlappedAsyncResult.cs
- WebErrorHandler.cs
- SerializerDescriptor.cs
- RsaElement.cs
- SamlAttribute.cs
- NativeMethods.cs
- TcpConnectionPoolSettingsElement.cs
- RemotingAttributes.cs
- TypeUtils.cs
- StreamInfo.cs
- WorkflowServiceNamespace.cs