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
- SqlDataSourceEnumerator.cs
- DataTableMapping.cs
- TextOnlyOutput.cs
- IListConverters.cs
- EncodingFallbackAwareXmlTextWriter.cs
- TextOutput.cs
- BamlBinaryWriter.cs
- _NestedMultipleAsyncResult.cs
- FacetValueContainer.cs
- XmlAttributeCache.cs
- HtmlInputRadioButton.cs
- SolidColorBrush.cs
- SoapFormatter.cs
- TraceXPathNavigator.cs
- WebPartExportVerb.cs
- Error.cs
- DesignerTransactionCloseEvent.cs
- JsonWriterDelegator.cs
- ScriptServiceAttribute.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- StorageAssociationSetMapping.cs
- XmlNodeReader.cs
- ReplacementText.cs
- QueryOperationResponseOfT.cs
- TheQuery.cs
- ImageListUtils.cs
- ContentOnlyMessage.cs
- CultureTable.cs
- Binding.cs
- SqlUtils.cs
- ProfilePropertySettingsCollection.cs
- HeaderedContentControl.cs
- TextEndOfParagraph.cs
- SystemTcpConnection.cs
- ConfigurationManagerInternal.cs
- BindingsCollection.cs
- MultiPropertyDescriptorGridEntry.cs
- Encoder.cs
- DrawingGroup.cs
- RegexCompilationInfo.cs
- SessionStateSection.cs
- PopupEventArgs.cs
- PngBitmapEncoder.cs
- OrderedHashRepartitionEnumerator.cs
- XmlWellformedWriter.cs
- PnrpPeerResolverElement.cs
- ISO2022Encoding.cs
- ArrayEditor.cs
- UnconditionalPolicy.cs
- SqlDataSourceQueryEditor.cs
- ObjectParameterCollection.cs
- GZipDecoder.cs
- WmfPlaceableFileHeader.cs
- PolicyValidationException.cs
- ObjectDataSourceSelectingEventArgs.cs
- StartUpEventArgs.cs
- EntityConnection.cs
- ItemChangedEventArgs.cs
- EventMappingSettingsCollection.cs
- NotifyParentPropertyAttribute.cs
- MenuItem.cs
- DispatcherOperation.cs
- DataSpaceManager.cs
- SinglePageViewer.cs
- Route.cs
- ComponentGlyph.cs
- BehaviorEditorPart.cs
- MatchingStyle.cs
- HostedTcpTransportManager.cs
- Rotation3DKeyFrameCollection.cs
- MetadataException.cs
- WebPartHelpVerb.cs
- PreloadedPackages.cs
- returneventsaver.cs
- DataTableNameHandler.cs
- InternalResources.cs
- XmlnsCache.cs
- ResourceSet.cs
- ModelTreeManager.cs
- TypeUtil.cs
- TraceData.cs
- DefaultWorkflowSchedulerService.cs
- xml.cs
- BufferedMessageData.cs
- RoleBoolean.cs
- SoapMessage.cs
- TreeNodeClickEventArgs.cs
- DrawingServices.cs
- WebPartCatalogCloseVerb.cs
- StreamInfo.cs
- AttributeCollection.cs
- HyperLinkColumn.cs
- QueryComponents.cs
- SqlSelectClauseBuilder.cs
- SQLSingle.cs
- Clause.cs
- CapabilitiesSection.cs
- ManagedWndProcTracker.cs
- ControlType.cs
- MembershipPasswordException.cs