Ejemplo n.º 1
0
        //Called by the WCF to create the binding element
        protected override BindingElement CreateBindingElement()
        {
            GZipMessageEncodingBindingElement bindingElement = new GZipMessageEncodingBindingElement();

            this.ApplyConfiguration(bindingElement);
            return(bindingElement);
        }
Ejemplo n.º 2
0
        //Called by the WCF to apply the configuration settings (the property above) to the binding element
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            GZipMessageEncodingBindingElement binding      = (GZipMessageEncodingBindingElement)bindingElement;
            PropertyInformationCollection     propertyInfo = this.ElementInformation.Properties;

            if (propertyInfo["innerMessageEncoding"].ValueOrigin != PropertyValueOrigin.Default)
            {
                switch (this.InnerMessageEncoding)
                {
                case "textMessageEncoding":
                    binding.InnerMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
                    break;

                case "binaryMessageEncoding":
                    binding.InnerMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
                    break;
                }
            }
            if (this.ReaderQuotas.ElementInformation.IsPresent)
            {
                XmlDictionaryReaderQuotasElement elementQuotas = this.ReaderQuotas;
                XmlDictionaryReaderQuotas        bindingQuotas = binding.ReaderQuotas;
                if (elementQuotas.MaxArrayLength != 0)
                {
                    bindingQuotas.MaxArrayLength = elementQuotas.MaxArrayLength;
                }
                if (elementQuotas.MaxBytesPerRead != 0)
                {
                    bindingQuotas.MaxBytesPerRead = elementQuotas.MaxBytesPerRead;
                }
                if (elementQuotas.MaxDepth != 0)
                {
                    bindingQuotas.MaxDepth = elementQuotas.MaxDepth;
                }
                if (elementQuotas.MaxNameTableCharCount != 0)
                {
                    bindingQuotas.MaxNameTableCharCount = elementQuotas.MaxNameTableCharCount;
                }
                if (elementQuotas.MaxStringContentLength != 0)
                {
                    bindingQuotas.MaxStringContentLength = elementQuotas.MaxStringContentLength;
                }
            }
        }