示例#1
0
        static void Main(string[] args)
        {
            // <Snippet0>
            // <Snippet1>
            var be = new BinaryMessageEncodingBindingElement();

            // </Snippet1>
            // <Snippet2>
            be.MaxReadPoolSize = 16;
            // </Snippet2>
            // <Snippet3>
            be.MaxSessionSize = 2048;
            // </Snippet3>
            // <Snippet4>
            be.MaxWritePoolSize = 16;
            // </Snippet4>
            // <Snippet5>
            be.MessageVersion = MessageVersion.Default;
            // </Snippet5>
            // <Snippet6>
            XmlDictionaryReaderQuotas quotas = be.ReaderQuotas;
            // </Snippet6>

            // <Snippet7>
            var binding = new CustomBinding();
            var bpCol   = new BindingParameterCollection();
            var context = new BindingContext(binding, bpCol);

            be.BuildChannelFactory <IDuplexChannel>(context);
            // </Snippet7>

            // <Snippet8>
            var binding2 = new CustomBinding();
            var bpCol2   = new BindingParameterCollection();
            var context2 = new BindingContext(binding2, bpCol2);

            be.BuildChannelListener <IDuplexChannel>(context2);
            // </Snippet8>

            // <Snippet9>
            be.CanBuildChannelListener <IDuplexChannel>(context2);
            // </Snippet9>
            // <Snippet10>
            BindingElement bindingElement = be.Clone();
            // </Snippet10>
            // <Snippet11>
            MessageEncoderFactory mef = be.CreateMessageEncoderFactory();
            // </Snippet11>
            // <Snippet12>
            MessageVersion mv = be.GetProperty <MessageVersion>(context);
            // </Snippet12>
            // </Snippet0>
        }
示例#2
0
		internal static BinaryMessageEncodingBindingElement CreateInnerEncodingBindingElement(BindingContext context)
		{
			BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement;
			if (context == null)
			{
				return ClientMessageUtility.defaultEncoderBindingElement;
			}
			BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement1 = context.BindingParameters.Find<BinaryMessageEncodingBindingElement>();
			if (binaryMessageEncodingBindingElement1 == null)
			{
				binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement();
				TextMessageEncodingBindingElement textMessageEncodingBindingElement = context.BindingParameters.Find<TextMessageEncodingBindingElement>();
				if (textMessageEncodingBindingElement == null)
				{
					MtomMessageEncodingBindingElement mtomMessageEncodingBindingElement = context.BindingParameters.Find<MtomMessageEncodingBindingElement>();
					if (mtomMessageEncodingBindingElement == null)
					{
						WebMessageEncodingBindingElement webMessageEncodingBindingElement = context.BindingParameters.Find<WebMessageEncodingBindingElement>();
						if (webMessageEncodingBindingElement != null)
						{
							webMessageEncodingBindingElement.ReaderQuotas.CopyTo(binaryMessageEncodingBindingElement.ReaderQuotas);
							binaryMessageEncodingBindingElement.MaxReadPoolSize = webMessageEncodingBindingElement.MaxReadPoolSize;
							binaryMessageEncodingBindingElement.MaxWritePoolSize = webMessageEncodingBindingElement.MaxWritePoolSize;
						}
					}
					else
					{
						mtomMessageEncodingBindingElement.ReaderQuotas.CopyTo(binaryMessageEncodingBindingElement.ReaderQuotas);
						binaryMessageEncodingBindingElement.MaxReadPoolSize = mtomMessageEncodingBindingElement.MaxReadPoolSize;
						binaryMessageEncodingBindingElement.MaxWritePoolSize = mtomMessageEncodingBindingElement.MaxWritePoolSize;
					}
				}
				else
				{
					textMessageEncodingBindingElement.ReaderQuotas.CopyTo(binaryMessageEncodingBindingElement.ReaderQuotas);
					binaryMessageEncodingBindingElement.MaxReadPoolSize = textMessageEncodingBindingElement.MaxReadPoolSize;
					binaryMessageEncodingBindingElement.MaxWritePoolSize = textMessageEncodingBindingElement.MaxWritePoolSize;
				}
			}
			else
			{
				binaryMessageEncodingBindingElement = binaryMessageEncodingBindingElement1.Clone() as BinaryMessageEncodingBindingElement;
			}
			return binaryMessageEncodingBindingElement;
		}