Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Xml / XmlDictionaryReaderQuotas.cs / 1305376 / XmlDictionaryReaderQuotas.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Xml { using System.Runtime.Serialization; using System.ComponentModel; 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; } [DefaultValue(DefaultMaxStringContentLength)] 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; } } [DefaultValue(DefaultMaxArrayLength)] 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; } } [DefaultValue(DefaultMaxBytesPerRead)] 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; } } [DefaultValue(DefaultMaxDepth)] 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; } } [DefaultValue(DefaultMaxNameTableCharCount)] 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. //----------------------------------------------------------- namespace System.Xml { using System.Runtime.Serialization; using System.ComponentModel; 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; } [DefaultValue(DefaultMaxStringContentLength)] 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; } } [DefaultValue(DefaultMaxArrayLength)] 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; } } [DefaultValue(DefaultMaxBytesPerRead)] 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; } } [DefaultValue(DefaultMaxDepth)] 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; } } [DefaultValue(DefaultMaxNameTableCharCount)] 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataColumnChangeEvent.cs
- NativeCompoundFileAPIs.cs
- SystemIPAddressInformation.cs
- mediapermission.cs
- SqlGatherProducedAliases.cs
- LabelInfo.cs
- TableCell.cs
- InputBuffer.cs
- DesignerVerbCollection.cs
- SqlServer2KCompatibilityAnnotation.cs
- ImageInfo.cs
- x509store.cs
- PackageRelationshipCollection.cs
- XPathConvert.cs
- ResponseBodyWriter.cs
- BitmapCacheBrush.cs
- recordstate.cs
- RSAPKCS1SignatureFormatter.cs
- SoapReflectionImporter.cs
- EmptyStringExpandableObjectConverter.cs
- ObjectDesignerDataSourceView.cs
- BasicHttpSecurityMode.cs
- RequestQueue.cs
- MultilineStringConverter.cs
- TransformerTypeCollection.cs
- DocumentViewerConstants.cs
- ConfigurationLockCollection.cs
- ConnectionManagementElement.cs
- PropertiesTab.cs
- SinglePhaseEnlistment.cs
- GridViewColumnHeaderAutomationPeer.cs
- BinaryMessageEncodingBindingElement.cs
- JsonStringDataContract.cs
- SQLInt32Storage.cs
- DesignerOptionService.cs
- UIHelper.cs
- WinEventTracker.cs
- DataAccessException.cs
- _NtlmClient.cs
- WebPart.cs
- ListItemsPage.cs
- UndoEngine.cs
- ClientRoleProvider.cs
- GeometryModel3D.cs
- XmlSchemaAnnotation.cs
- MsmqIntegrationSecurity.cs
- ReadWriteSpinLock.cs
- BindingContext.cs
- xmlfixedPageInfo.cs
- WebPartCollection.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- LocalizationComments.cs
- SequenceFullException.cs
- Block.cs
- MaterialGroup.cs
- URLIdentityPermission.cs
- Method.cs
- DataTableCollection.cs
- UnsafeNativeMethods.cs
- ElementUtil.cs
- SspiSafeHandles.cs
- TableAdapterManagerGenerator.cs
- ApplicationId.cs
- DescriptionAttribute.cs
- GridViewItemAutomationPeer.cs
- LocalBuilder.cs
- FixedSOMPageElement.cs
- DataGridDetailsPresenterAutomationPeer.cs
- UnknownBitmapDecoder.cs
- WebPartUtil.cs
- Bold.cs
- WebPartConnectionsCloseVerb.cs
- XPathNodeInfoAtom.cs
- CookielessHelper.cs
- Int32RectValueSerializer.cs
- HMACSHA256.cs
- XmlnsDictionary.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- URI.cs
- DataGridViewColumnStateChangedEventArgs.cs
- SystemTcpStatistics.cs
- BinaryCommonClasses.cs
- DataGridViewCellEventArgs.cs
- StorageMappingItemCollection.cs
- SQLBytes.cs
- GPRECTF.cs
- UserNameSecurityTokenAuthenticator.cs
- XamlStream.cs
- ObjectReferenceStack.cs
- XamlRtfConverter.cs
- BackgroundWorker.cs
- TextUtf8RawTextWriter.cs
- Guid.cs
- ToolBarOverflowPanel.cs
- HiddenField.cs
- NegationPusher.cs
- MatrixAnimationUsingPath.cs
- DataGridCommandEventArgs.cs
- UserControlParser.cs
- DataGridHeaderBorder.cs