Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Serialization / System / Xml / XmlDictionaryReaderQuotas.cs / 1 / XmlDictionaryReaderQuotas.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Xml { using System.Runtime.Serialization; public sealed class XmlDictionaryReaderQuotas { bool readOnly; int maxStringContentLength; int maxArrayLength; int maxDepth; int maxNameTableCharCount; int maxBytesPerRead; const int DefaultMaxDepth = 32; const int DefaultMaxStringContentLength = 8192; const int DefaultMaxArrayLength = 16384; const int DefaultMaxBytesPerRead = 4096; const int DefaultMaxNameTableCharCount = 16384; static XmlDictionaryReaderQuotas defaultQuota = new XmlDictionaryReaderQuotas(DefaultMaxDepth, DefaultMaxStringContentLength, DefaultMaxArrayLength, DefaultMaxBytesPerRead, DefaultMaxNameTableCharCount); static XmlDictionaryReaderQuotas maxQuota = new XmlDictionaryReaderQuotas(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue); public XmlDictionaryReaderQuotas() { defaultQuota.CopyTo(this); } XmlDictionaryReaderQuotas(int maxDepth, int maxStringContentLength, int maxArrayLength, int maxBytesPerRead, int maxNameTableCharCount) { this.maxDepth = maxDepth; this.maxStringContentLength = maxStringContentLength; this.maxArrayLength = maxArrayLength; this.maxBytesPerRead = maxBytesPerRead; this.maxNameTableCharCount = maxNameTableCharCount; MakeReadOnly(); } static public XmlDictionaryReaderQuotas Max { get { return maxQuota; } } public void CopyTo(XmlDictionaryReaderQuotas quotas) { if (quotas == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("quotas")); if (quotas.readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaCopyReadOnly))); InternalCopyTo(quotas); } internal void InternalCopyTo(XmlDictionaryReaderQuotas quotas) { quotas.maxStringContentLength = this.maxStringContentLength; quotas.maxArrayLength = this.maxArrayLength; quotas.maxDepth = this.MaxDepth; quotas.maxNameTableCharCount = this.maxNameTableCharCount; quotas.maxBytesPerRead = this.maxBytesPerRead; } public int MaxStringContentLength { get { return maxStringContentLength; } set { if (readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaIsReadOnly, "MaxStringContentLength"))); if (value <= 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.QuotaMustBePositive), "value")); maxStringContentLength = value; } } public int MaxArrayLength { get { return maxArrayLength; } set { if (readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaIsReadOnly, "MaxArrayLength"))); if (value <= 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.QuotaMustBePositive), "value")); maxArrayLength = value; } } public int MaxBytesPerRead { get { return maxBytesPerRead; } set { if (readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaIsReadOnly, "MaxBytesPerRead"))); if (value <= 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.QuotaMustBePositive), "value")); maxBytesPerRead = value; } } public int MaxDepth { get { return maxDepth; } set { if (readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaIsReadOnly, "MaxDepth"))); if (value <= 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.QuotaMustBePositive), "value")); maxDepth = value; } } public int MaxNameTableCharCount { get { return maxNameTableCharCount; } set { if (readOnly) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaIsReadOnly, "MaxNameTableCharCount"))); if (value <= 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.QuotaMustBePositive), "value")); maxNameTableCharCount = value; } } internal void MakeReadOnly() { this.readOnly = true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MSAANativeProvider.cs
- HwndSource.cs
- EncryptedData.cs
- SerialReceived.cs
- TargetControlTypeCache.cs
- ReferentialConstraint.cs
- BCLDebug.cs
- DataGridViewAccessibleObject.cs
- DataContractJsonSerializerOperationBehavior.cs
- filewebresponse.cs
- TextTreeDeleteContentUndoUnit.cs
- ComponentChangedEvent.cs
- UdpTransportSettingsElement.cs
- Point4DConverter.cs
- LOSFormatter.cs
- XmlDigitalSignatureProcessor.cs
- ExpressionLink.cs
- StateMachine.cs
- Listen.cs
- IssuedTokenParametersElement.cs
- HttpPostedFile.cs
- PersonalizableAttribute.cs
- Int16.cs
- DataGridRowAutomationPeer.cs
- AttributedMetaModel.cs
- IgnoreSectionHandler.cs
- ConstraintEnumerator.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- BitmapDecoder.cs
- BitmapEffectInputData.cs
- DnsElement.cs
- NameValueConfigurationElement.cs
- DictionaryEntry.cs
- PropertyEmitter.cs
- X509Certificate.cs
- ValueProviderWrapper.cs
- AssemblyCacheEntry.cs
- SecurityPermission.cs
- PersistenceProviderBehavior.cs
- SwitchLevelAttribute.cs
- DecimalAnimation.cs
- FrameworkContentElement.cs
- JulianCalendar.cs
- Splitter.cs
- DefaultPrintController.cs
- ExpressionEditorAttribute.cs
- XmlSecureResolver.cs
- Enum.cs
- XmlNamespaceMapping.cs
- SizeLimitedCache.cs
- __Filters.cs
- IISUnsafeMethods.cs
- XmlDictionaryString.cs
- DesignerTransaction.cs
- HighContrastHelper.cs
- XamlDesignerSerializationManager.cs
- JavaScriptString.cs
- ISAPIRuntime.cs
- Pipe.cs
- LineSegment.cs
- RpcCryptoRequest.cs
- DataGridViewElement.cs
- Formatter.cs
- EdmError.cs
- EnvelopedPkcs7.cs
- VBIdentifierName.cs
- SingletonChannelAcceptor.cs
- SqlConnectionHelper.cs
- TimeSpanStorage.cs
- Int32AnimationUsingKeyFrames.cs
- _LocalDataStore.cs
- TextProperties.cs
- httpapplicationstate.cs
- EditorPartChrome.cs
- WaitForChangedResult.cs
- InternalDispatchObject.cs
- QilFunction.cs
- StreamAsIStream.cs
- xmlglyphRunInfo.cs
- StructuralType.cs
- ObjectListCommandEventArgs.cs
- ClientOperationFormatterProvider.cs
- Mapping.cs
- CanExpandCollapseAllConverter.cs
- DefaultAssemblyResolver.cs
- EdmComplexPropertyAttribute.cs
- Latin1Encoding.cs
- XmlSchemaValidationException.cs
- HttpEncoderUtility.cs
- ChannelEndpointElementCollection.cs
- ActivityBuilder.cs
- CodeMemberEvent.cs
- DefaultEventAttribute.cs
- RuntimeCompatibilityAttribute.cs
- TypeLoadException.cs
- DataQuery.cs
- XmlSerializerVersionAttribute.cs
- FileSystemWatcher.cs
- XmlDsigSep2000.cs
- MouseCaptureWithinProperty.cs