Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TextMessageEncodingBindingElement.cs / 1 / TextMessageEncodingBindingElement.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
using System.ServiceModel.Description;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Xml;
public sealed class TextMessageEncodingBindingElement : MessageEncodingBindingElement, IWsdlExportExtension, IPolicyExportExtension
{
int maxReadPoolSize;
int maxWritePoolSize;
XmlDictionaryReaderQuotas readerQuotas;
MessageVersion messageVersion;
Encoding writeEncoding;
public TextMessageEncodingBindingElement()
: this(MessageVersion.Default, TextEncoderDefaults.Encoding)
{
}
public TextMessageEncodingBindingElement(MessageVersion messageVersion, Encoding writeEncoding)
{
if (messageVersion == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
if (writeEncoding == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
TextEncoderDefaults.ValidateEncoding(writeEncoding);
this.maxReadPoolSize = EncoderDefaults.MaxReadPoolSize;
this.maxWritePoolSize = EncoderDefaults.MaxWritePoolSize;
this.readerQuotas = new XmlDictionaryReaderQuotas();
EncoderDefaults.ReaderQuotas.CopyTo(this.readerQuotas);
this.messageVersion = messageVersion;
this.writeEncoding = writeEncoding;
}
TextMessageEncodingBindingElement(TextMessageEncodingBindingElement elementToBeCloned)
: base(elementToBeCloned)
{
this.maxReadPoolSize = elementToBeCloned.maxReadPoolSize;
this.maxWritePoolSize = elementToBeCloned.maxWritePoolSize;
this.readerQuotas = new XmlDictionaryReaderQuotas();
elementToBeCloned.readerQuotas.CopyTo(this.readerQuotas);
this.writeEncoding = elementToBeCloned.writeEncoding;
this.messageVersion = elementToBeCloned.messageVersion;
}
public int MaxReadPoolSize
{
get
{
return this.maxReadPoolSize;
}
set
{
if (value <= 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
SR.GetString(SR.ValueMustBePositive)));
}
this.maxReadPoolSize = value;
}
}
public int MaxWritePoolSize
{
get
{
return this.maxWritePoolSize;
}
set
{
if (value <= 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
SR.GetString(SR.ValueMustBePositive)));
}
this.maxWritePoolSize = value;
}
}
public XmlDictionaryReaderQuotas ReaderQuotas
{
get
{
return this.readerQuotas;
}
}
public override MessageVersion MessageVersion
{
get
{
return this.messageVersion;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
this.messageVersion = value;
}
}
public Encoding WriteEncoding
{
get
{
return this.writeEncoding;
}
set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
}
TextEncoderDefaults.ValidateEncoding(value);
this.writeEncoding = value;
}
}
public override IChannelFactory BuildChannelFactory(BindingContext context)
{
return InternalBuildChannelFactory(context);
}
public override IChannelListener BuildChannelListener(BindingContext context)
{
return InternalBuildChannelListener(context);
}
public override bool CanBuildChannelListener(BindingContext context)
{
return InternalCanBuildChannelListener(context);
}
public override BindingElement Clone()
{
return new TextMessageEncodingBindingElement(this);
}
public override MessageEncoderFactory CreateMessageEncoderFactory()
{
return new TextMessageEncoderFactory(MessageVersion, WriteEncoding, this.MaxReadPoolSize, this.MaxWritePoolSize, this.ReaderQuotas);
}
public override T GetProperty(BindingContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
{
return (T)(object)this.readerQuotas;
}
else
{
return base.GetProperty(context);
}
}
void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
}
void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context) { }
void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
SoapHelper.SetSoapVersion(context, exporter, this.messageVersion.Envelope);
}
internal override bool CheckEncodingVersion(EnvelopeVersion version)
{
return messageVersion.Envelope == version;
}
internal override bool IsMatch(BindingElement b)
{
if (!base.IsMatch(b))
return false;
TextMessageEncodingBindingElement text = b as TextMessageEncodingBindingElement;
if (text == null)
return false;
if (this.maxReadPoolSize != text.MaxReadPoolSize)
return false;
if (this.maxWritePoolSize != text.MaxWritePoolSize)
return false;
// compare XmlDictionaryReaderQuotas
if (this.readerQuotas.MaxStringContentLength != text.ReaderQuotas.MaxStringContentLength)
return false;
if (this.readerQuotas.MaxArrayLength != text.ReaderQuotas.MaxArrayLength)
return false;
if (this.readerQuotas.MaxBytesPerRead != text.ReaderQuotas.MaxBytesPerRead)
return false;
if (this.readerQuotas.MaxDepth != text.ReaderQuotas.MaxDepth)
return false;
if (this.readerQuotas.MaxNameTableCharCount != text.ReaderQuotas.MaxNameTableCharCount)
return false;
if (this.WriteEncoding.EncodingName != text.WriteEncoding.EncodingName)
return false;
if (!this.MessageVersion.IsMatch(text.MessageVersion))
return false;
return 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
- StackSpiller.Bindings.cs
- SQLBinary.cs
- InheritanceService.cs
- AnnotationResource.cs
- PageParser.cs
- DataListItemCollection.cs
- XmlArrayItemAttribute.cs
- StringExpressionSet.cs
- HttpDictionary.cs
- ErrorLog.cs
- Trace.cs
- XmlChoiceIdentifierAttribute.cs
- RelationshipSet.cs
- PixelFormatConverter.cs
- OutputCacheSettings.cs
- ToolStripOverflow.cs
- CacheAxisQuery.cs
- ImageUrlEditor.cs
- PersistenceProviderElement.cs
- ButtonChrome.cs
- BinaryCommonClasses.cs
- FileInfo.cs
- RSAPKCS1SignatureDeformatter.cs
- Grammar.cs
- OdbcErrorCollection.cs
- EntityKeyElement.cs
- BamlResourceSerializer.cs
- MouseBinding.cs
- CursorConverter.cs
- QilPatternFactory.cs
- Rotation3D.cs
- DesignTimeTemplateParser.cs
- HMAC.cs
- PageFunction.cs
- DataBoundLiteralControl.cs
- DataGridCell.cs
- UrlPath.cs
- WindowsIdentity.cs
- Attributes.cs
- SecurityTokenTypes.cs
- LineBreakRecord.cs
- Point3DConverter.cs
- DebugInfo.cs
- SoapTypeAttribute.cs
- KnownBoxes.cs
- TemplatePartAttribute.cs
- Sql8ConformanceChecker.cs
- ReliableInputConnection.cs
- SkewTransform.cs
- SqlNotificationRequest.cs
- XmlAttributeHolder.cs
- LocalFileSettingsProvider.cs
- Int32RectValueSerializer.cs
- DateTimeOffset.cs
- DataView.cs
- ModuleBuilderData.cs
- LocalServiceSecuritySettingsElement.cs
- OperationFormatUse.cs
- ObjectQueryProvider.cs
- Point3DAnimationBase.cs
- DocumentsTrace.cs
- GridPattern.cs
- FamilyCollection.cs
- RequestSecurityToken.cs
- DataControlField.cs
- SemaphoreSlim.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- AddDataControlFieldDialog.cs
- RadioButtonAutomationPeer.cs
- TypeViewSchema.cs
- StreamResourceInfo.cs
- smtppermission.cs
- Label.cs
- QilCloneVisitor.cs
- ColorBlend.cs
- TypeSystem.cs
- UndoManager.cs
- iisPickupDirectory.cs
- CompModSwitches.cs
- QuaternionRotation3D.cs
- SerializationAttributes.cs
- UIElement.cs
- FormatException.cs
- ThaiBuddhistCalendar.cs
- RijndaelManaged.cs
- Facet.cs
- DataGridRow.cs
- ObjectStorage.cs
- ObjectStateManagerMetadata.cs
- TextEffectCollection.cs
- RawUIStateInputReport.cs
- SynchronousChannel.cs
- AvTraceFormat.cs
- DataSetMappper.cs
- SetterBaseCollection.cs
- versioninfo.cs
- Utils.cs
- InternalPermissions.cs
- BoundField.cs
- SnapshotChangeTrackingStrategy.cs