コード例 #1
0
        // Called by the WCF to create the binding element
        protected override BindingElement CreateBindingElement()
        {
            RawMessageEncodingBindingElement bindingElement = new RawMessageEncodingBindingElement();

            this.ApplyConfiguration(bindingElement);
            return(bindingElement);
        }
コード例 #2
0
        // Called by the WCF to apply the configuration settings (the property above) to the binding element
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            RawMessageEncodingBindingElement binding      = (RawMessageEncodingBindingElement)bindingElement;
            PropertyInformationCollection    propertyInfo = this.ElementInformation.Properties;
            var propertyInformation = propertyInfo["innerMessageEncoding"];

            if (propertyInformation != null && propertyInformation.ValueOrigin != PropertyValueOrigin.Default)
            {
                switch (this.InnerMessageEncoding)
                {
                case "textMessageEncoding":
                    binding.InnerMessageEncodingBindingElement = new TextMessageEncodingBindingElement();
                    break;

                case "binaryMessageEncoding":
                    binding.InnerMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
                    break;
                }
            }
        }