Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Configuration / WebMessageEncodingElement.cs / 1 / WebMessageEncodingElement.cs
// Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ #pragma warning disable 1634 // Stops compiler from warning about unknown warnings (for Presharp) namespace System.ServiceModel.Configuration { using System.ComponentModel; using System.Configuration; using System.ServiceModel.Channels; using System.Text; using System.Xml; public sealed partial class WebMessageEncodingElement : BindingElementExtensionElement { const string ConfigurationStringsWebContentTypeMapperType = "webContentTypeMapperType"; public WebMessageEncodingElement() { } [System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration102:ConfigurationPropertyAttributeRule", MessageId = "System.ServiceModel.Configuration.WebMessageEncodingElement.BindingElementType", Justification = "Not a configurable property; a property that had to be overridden from abstract parent class")] public override Type BindingElementType { get { return typeof(WebMessageEncodingBindingElement); } } [ConfigurationProperty(ConfigurationStrings.MaxReadPoolSize, DefaultValue = EncoderDefaults.MaxReadPoolSize)] [IntegerValidator(MinValue = 1)] public int MaxReadPoolSize { get { return (int) base[ConfigurationStrings.MaxReadPoolSize]; } set { base[ConfigurationStrings.MaxReadPoolSize] = value; } } [ConfigurationProperty(ConfigurationStrings.MaxWritePoolSize, DefaultValue = EncoderDefaults.MaxWritePoolSize)] [IntegerValidator(MinValue = 1)] public int MaxWritePoolSize { get { return (int) base[ConfigurationStrings.MaxWritePoolSize]; } set { base[ConfigurationStrings.MaxWritePoolSize] = value; } } [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] public XmlDictionaryReaderQuotasElement ReaderQuotas { get { return (XmlDictionaryReaderQuotasElement) base[ConfigurationStrings.ReaderQuotas]; } } [ConfigurationProperty(ConfigurationStringsWebContentTypeMapperType, DefaultValue = "")] [StringValidator(MinLength = 0)] public string WebContentTypeMapperType { get { return (string) base[ConfigurationStringsWebContentTypeMapperType]; } set { if (String.IsNullOrEmpty(value)) { value = String.Empty; } base[ConfigurationStringsWebContentTypeMapperType] = value; } } [ConfigurationProperty(ConfigurationStrings.WriteEncoding, DefaultValue = TextEncoderDefaults.EncodingString)] [TypeConverter(typeof(EncodingConverter))] [WebEncodingValidator] [System.Diagnostics.CodeAnalysis.SuppressMessage("Configuration", "Configuration104:ConfigurationValidatorAttributeRule", MessageId = "System.ServiceModel.Configuration.WebMessageEncodingElement.WriteEncoding", Justification = "Bug with internal FxCop assembly flags this property as not having a validator.")] public Encoding WriteEncoding { get { return (Encoding) base[ConfigurationStrings.WriteEncoding]; } set { base[ConfigurationStrings.WriteEncoding] = value; } } public override void ApplyConfiguration(BindingElement bindingElement) { base.ApplyConfiguration(bindingElement); WebMessageEncodingBindingElement binding = (WebMessageEncodingBindingElement) bindingElement; binding.WriteEncoding = this.WriteEncoding; binding.MaxReadPoolSize = this.MaxReadPoolSize; binding.MaxWritePoolSize = this.MaxWritePoolSize; if (!string.IsNullOrEmpty(this.WebContentTypeMapperType)) { Type CTMType = Type.GetType(this.WebContentTypeMapperType, true); if (!typeof(WebContentTypeMapper).IsAssignableFrom(CTMType)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException( SR2.GetString(SR2.ConfigInvalidWebContentTypeMapper, CTMType, ConfigurationStringsWebContentTypeMapperType, typeof(WebMessageEncodingBindingElement), typeof(WebContentTypeMapper)))); } try { binding.ContentTypeMapper = (WebContentTypeMapper) Activator.CreateInstance(CTMType); } catch (MissingMethodException innerException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException( SR2.GetString(SR2.ConfigWebContentTypeMapperNoConstructor, CTMType, ConfigurationStringsWebContentTypeMapperType, typeof(WebMessageEncodingBindingElement), typeof(WebContentTypeMapper)), innerException)); } } #pragma warning suppress 56506 // bindingElement is checked for null in base.ApplyConfiguration() ApplyConfiguration(this.ReaderQuotas, binding.ReaderQuotas); } public override void CopyFrom(ServiceModelExtensionElement from) { base.CopyFrom(from); WebMessageEncodingElement source = (WebMessageEncodingElement) from; #pragma warning suppress 56506 // base.CopyFrom() checks for 'from' being null this.WriteEncoding = source.WriteEncoding; this.MaxReadPoolSize = source.MaxReadPoolSize; this.MaxWritePoolSize = source.MaxWritePoolSize; this.WebContentTypeMapperType = source.WebContentTypeMapperType; this.ReaderQuotas.MaxArrayLength = source.ReaderQuotas.MaxArrayLength; this.ReaderQuotas.MaxBytesPerRead = source.ReaderQuotas.MaxBytesPerRead; this.ReaderQuotas.MaxDepth = source.ReaderQuotas.MaxDepth; this.ReaderQuotas.MaxNameTableCharCount = source.ReaderQuotas.MaxNameTableCharCount; this.ReaderQuotas.MaxStringContentLength = source.ReaderQuotas.MaxStringContentLength; } internal protected override BindingElement CreateBindingElement() { WebMessageEncodingBindingElement binding = new WebMessageEncodingBindingElement(); this.ApplyConfiguration(binding); return binding; } internal void ApplyConfiguration(XmlDictionaryReaderQuotasElement currentQuotas, XmlDictionaryReaderQuotas readerQuotas) { if (readerQuotas == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerQuotas"); } if (currentQuotas.MaxDepth != 0) { readerQuotas.MaxDepth = currentQuotas.MaxDepth; } if (currentQuotas.MaxStringContentLength != 0) { readerQuotas.MaxStringContentLength = currentQuotas.MaxStringContentLength; } if (currentQuotas.MaxArrayLength != 0) { readerQuotas.MaxArrayLength = currentQuotas.MaxArrayLength; } if (currentQuotas.MaxBytesPerRead != 0) { readerQuotas.MaxBytesPerRead = currentQuotas.MaxBytesPerRead; } if (currentQuotas.MaxNameTableCharCount != 0) { readerQuotas.MaxNameTableCharCount = currentQuotas.MaxNameTableCharCount; } } } } // 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
- WebHttpSecurityModeHelper.cs
- ServiceAuthorizationManager.cs
- CultureNotFoundException.cs
- IncrementalCompileAnalyzer.cs
- WindowsClientCredential.cs
- CodeTypeDelegate.cs
- ImageSource.cs
- OuterGlowBitmapEffect.cs
- MappedMetaModel.cs
- BitmapMetadataEnumerator.cs
- ReferentialConstraintRoleElement.cs
- MimeParameters.cs
- Stylesheet.cs
- SQLInt16.cs
- IIS7UserPrincipal.cs
- WindowsStreamSecurityElement.cs
- SafeCertificateStore.cs
- WindowsComboBox.cs
- SHA512.cs
- ExpressionHelper.cs
- ConnectivityStatus.cs
- EmulateRecognizeCompletedEventArgs.cs
- ModelVisual3D.cs
- GenericIdentity.cs
- ImageFormatConverter.cs
- MaskedTextBoxDesigner.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- KeyNotFoundException.cs
- OdbcInfoMessageEvent.cs
- UIElementCollection.cs
- Vector3DAnimationBase.cs
- SingleResultAttribute.cs
- TransformerTypeCollection.cs
- RootBrowserWindowAutomationPeer.cs
- SafeArrayTypeMismatchException.cs
- CachedPathData.cs
- TextEditorSpelling.cs
- Light.cs
- Animatable.cs
- HttpListenerRequestTraceRecord.cs
- PageCanvasSize.cs
- EntityRecordInfo.cs
- DataBoundControlHelper.cs
- MsmqInputChannelBase.cs
- recordstate.cs
- TextServicesContext.cs
- HealthMonitoringSectionHelper.cs
- EntityStoreSchemaFilterEntry.cs
- Source.cs
- ResourceContainer.cs
- XsltInput.cs
- WindowsFormsEditorServiceHelper.cs
- IteratorFilter.cs
- WebPartTransformer.cs
- MiniMapControl.xaml.cs
- DescriptionAttribute.cs
- FixedSOMPageConstructor.cs
- GeneralTransform3DGroup.cs
- AvTrace.cs
- ErrorWrapper.cs
- InkCollectionBehavior.cs
- RolePrincipal.cs
- XmlDigitalSignatureProcessor.cs
- ReadOnlyDictionary.cs
- AttachedAnnotationChangedEventArgs.cs
- VisualBasicSettings.cs
- TextSearch.cs
- StringFormat.cs
- dbdatarecord.cs
- ThicknessAnimationBase.cs
- CursorConverter.cs
- EmptyControlCollection.cs
- HwndSourceKeyboardInputSite.cs
- TreeViewAutomationPeer.cs
- InheritanceContextChangedEventManager.cs
- LinqDataSourceHelper.cs
- XmlSchemaInclude.cs
- ResponseStream.cs
- Timer.cs
- EnumDataContract.cs
- WindowsFormsSectionHandler.cs
- ToolBarButtonClickEvent.cs
- XmlToDatasetMap.cs
- DependencyPropertyConverter.cs
- StylusButtonEventArgs.cs
- Char.cs
- LongValidatorAttribute.cs
- Label.cs
- HierarchicalDataBoundControlAdapter.cs
- MouseCaptureWithinProperty.cs
- SerializationException.cs
- selecteditemcollection.cs
- versioninfo.cs
- CreateDataSourceDialog.cs
- XhtmlBasicPageAdapter.cs
- ObjectHelper.cs
- XmlSchemaImporter.cs
- _NetworkingPerfCounters.cs
- CuspData.cs
- PingReply.cs