ByteStreamMessageEncodingElement.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Channels / System / ServiceModel / Configuration / ByteStreamMessageEncodingElement.cs / 1305376 / ByteStreamMessageEncodingElement.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Configuration 
{
    using System.Configuration; 
    using System.Runtime; 
    using System.ServiceModel.Channels;
    using System.ServiceModel.Configuration; 
    using System.Xml;
    using System.Diagnostics.CodeAnalysis;

    public sealed partial class ByteStreamMessageEncodingElement : BindingElementExtensionElement 
    {
        public ByteStreamMessageEncodingElement() 
        { 
        }
 
        [SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationPropertyAttributeRule, Justification = "this property not a configuration property")]
        public override Type BindingElementType
        {
            get { return typeof(ByteStreamMessageEncodingBindingElement); } 
        }
 
        [ConfigurationProperty(ByteStreamConfigurationStrings.ReaderQuotas)] 
        public XmlDictionaryReaderQuotasElement ReaderQuotas
        { 
            get { return (XmlDictionaryReaderQuotasElement)base[ByteStreamConfigurationStrings.ReaderQuotas]; }
        }

        public override void ApplyConfiguration(BindingElement bindingElement) 
        {
            base.ApplyConfiguration(bindingElement); 
            ByteStreamMessageEncodingBindingElement binding = (ByteStreamMessageEncodingBindingElement)bindingElement; 

            this.ApplyConfiguration(binding.ReaderQuotas); 
        }

        public override void CopyFrom(ServiceModelExtensionElement from)
        { 
            base.CopyFrom(from);
            ByteStreamMessageEncodingElement source = (ByteStreamMessageEncodingElement)from; 
 
            this.CopyFrom(source.ReaderQuotas);
        } 

        protected internal override void InitializeFrom(BindingElement bindingElement)
        {
            base.InitializeFrom(bindingElement); 
            ByteStreamMessageEncodingBindingElement element = (ByteStreamMessageEncodingBindingElement)bindingElement;
 
            this.InitializeFrom(element.ReaderQuotas); 
        }
 
        protected internal override BindingElement CreateBindingElement()
        {
            ByteStreamMessageEncodingBindingElement binding = new ByteStreamMessageEncodingBindingElement();
            this.ApplyConfiguration(binding); 
            return binding;
        } 
 
        void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
        { 
            if (readerQuotas == null)
            {
                throw FxTrace.Exception.ArgumentNull("readerQuotas");
            } 

            XmlDictionaryReaderQuotasElement oldQuotas = this.ReaderQuotas; 
 
            if (oldQuotas.MaxDepth != 0)
            { 
                readerQuotas.MaxDepth = oldQuotas.MaxDepth;
            }
            if (oldQuotas.MaxStringContentLength != 0)
            { 
                readerQuotas.MaxStringContentLength = oldQuotas.MaxStringContentLength;
            } 
            if (oldQuotas.MaxArrayLength != 0) 
            {
                readerQuotas.MaxArrayLength = oldQuotas.MaxArrayLength; 
            }
            if (oldQuotas.MaxBytesPerRead != 0)
            {
                readerQuotas.MaxBytesPerRead = oldQuotas.MaxBytesPerRead; 
            }
            if (oldQuotas.MaxNameTableCharCount != 0) 
            { 
                readerQuotas.MaxNameTableCharCount = oldQuotas.MaxNameTableCharCount;
            } 
        }

        void InitializeFrom(XmlDictionaryReaderQuotas readerQuotas)
        { 
            XmlDictionaryReaderQuotasElement thisQuotas = this.ReaderQuotas;
 
            thisQuotas.MaxDepth = readerQuotas.MaxDepth; 
            thisQuotas.MaxStringContentLength = readerQuotas.MaxStringContentLength;
            thisQuotas.MaxArrayLength = readerQuotas.MaxArrayLength; 
            thisQuotas.MaxBytesPerRead = readerQuotas.MaxBytesPerRead;
            thisQuotas.MaxNameTableCharCount = readerQuotas.MaxNameTableCharCount;
        }
 
        void CopyFrom(XmlDictionaryReaderQuotasElement readerQuotas)
        { 
            XmlDictionaryReaderQuotasElement thisQuotas = this.ReaderQuotas; 

            thisQuotas.MaxDepth = readerQuotas.MaxDepth; 
            thisQuotas.MaxStringContentLength = readerQuotas.MaxStringContentLength;
            thisQuotas.MaxArrayLength = readerQuotas.MaxArrayLength;
            thisQuotas.MaxBytesPerRead = readerQuotas.MaxBytesPerRead;
            thisQuotas.MaxNameTableCharCount = readerQuotas.MaxNameTableCharCount; 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK