当前位置: 首页>>代码示例>>C#>>正文


C# BindingContext.GetInnerProperty方法代码示例

本文整理汇总了C#中BindingContext.GetInnerProperty方法的典型用法代码示例。如果您正苦于以下问题:C# BindingContext.GetInnerProperty方法的具体用法?C# BindingContext.GetInnerProperty怎么用?C# BindingContext.GetInnerProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BindingContext的用法示例。


在下文中一共展示了BindingContext.GetInnerProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IncreaseBindingQuotas

        /// <summary>
        /// Increases the quotas in the specified binding.
        /// </summary>        
        public static Binding IncreaseBindingQuotas(Binding binding)
        {
            CustomBinding newBinding = new CustomBinding(binding);
            newBinding.ReceiveTimeout = TimeSpan.MaxValue;
            newBinding.SendTimeout = TimeSpan.MaxValue;

            BindingContext bcontext = new BindingContext(newBinding, new BindingParameterCollection());
            XmlDictionaryReaderQuotas xmlDictReaderQuotas = bcontext.GetInnerProperty<XmlDictionaryReaderQuotas>();

            if (xmlDictReaderQuotas != null)
            {
                xmlDictReaderQuotas.MaxArrayLength = int.MaxValue;
                xmlDictReaderQuotas.MaxBytesPerRead = int.MaxValue;
                xmlDictReaderQuotas.MaxDepth = int.MaxValue;
                xmlDictReaderQuotas.MaxNameTableCharCount = int.MaxValue;
                xmlDictReaderQuotas.MaxStringContentLength = int.MaxValue;
            }

            TransportBindingElement transport = bcontext.RemainingBindingElements.Find<TransportBindingElement>();

            if (transport != null)
            {
                if (typeof (HttpTransportBindingElement) == transport.GetType()) // http
                {
                    HttpTransportBindingElement httpTransport = transport as HttpTransportBindingElement;

                    // Are we on a streaming transport? Then we can make MaxReceivedMessageSize to 
                    // long.MaxValue. Otherwise we have to set it to int.MaxValue as that's the max buffer size.
                    if (httpTransport.TransferMode == TransferMode.Streamed ||
                        httpTransport.TransferMode == TransferMode.StreamedRequest)
                    {
                        httpTransport.MaxReceivedMessageSize = long.MaxValue;
                    }
                    else
                    {
                        httpTransport.MaxReceivedMessageSize = int.MaxValue;
                    }
                    httpTransport.MaxBufferSize = int.MaxValue;
                }
                else if (typeof (TcpTransportBindingElement) == transport.GetType()) // tcp                            
                {
                    TcpTransportBindingElement tcpTransport = transport as TcpTransportBindingElement;

                    if (tcpTransport.TransferMode == TransferMode.Streamed ||
                        tcpTransport.TransferMode == TransferMode.StreamedRequest)
                    {
                        tcpTransport.MaxReceivedMessageSize = long.MaxValue;
                    }
                    else
                    {
                        tcpTransport.MaxReceivedMessageSize = int.MaxValue;
                    }
                    tcpTransport.MaxBufferSize = int.MaxValue;
                }
                else if (typeof (NamedPipeTransportBindingElement) == transport.GetType()) // pipe
                {
                    NamedPipeTransportBindingElement pipeTransport = transport as NamedPipeTransportBindingElement;

                    if (pipeTransport.TransferMode == TransferMode.Streamed ||
                        pipeTransport.TransferMode == TransferMode.StreamedRequest)
                    {
                        pipeTransport.MaxReceivedMessageSize = long.MaxValue;
                    }
                    else
                    {
                        pipeTransport.MaxReceivedMessageSize = int.MaxValue;
                    }
                    pipeTransport.MaxBufferSize = int.MaxValue;
                }
                else if (typeof (MsmqTransportBindingElement) == transport.GetType()) // msmq
                {
                    MsmqTransportBindingElement msmqTrasport = transport as MsmqTransportBindingElement;
                    msmqTrasport.MaxReceivedMessageSize = long.MaxValue;
                }
                else
                {
                    // We don't know the transport type (probably a custom transport). So let's max it out to the int.MaxValue.
                    transport.MaxReceivedMessageSize = int.MaxValue;
                }
            }

            return newBinding;
        }
开发者ID:ChristianWeyer,项目名称:Thinktecture.ServiceModel,代码行数:86,代码来源:BindingController.cs

示例2: VerifyBindingSettings

        /// <summary>
        /// Verifies that the throttling settings in a given binding are maxed out.
        /// </summary>
        private void VerifyBindingSettings(Binding binding)
        {
            CustomBinding customBinding = new CustomBinding(binding);
            BindingContext bctx = new BindingContext(customBinding, new BindingParameterCollection());

            // Verify binding timeouts.
            VerifyBindingTimeouts(binding);

            // Verify the XmlDictionaryReaderQuotas.
            XmlDictionaryReaderQuotas dictQuotas = bctx.GetInnerProperty<XmlDictionaryReaderQuotas>();
            VerifyXmlDictionaryReaderQuotas(dictQuotas, binding.Name);

            // Verify the transport.
            TransportBindingElement transport = bctx.RemainingBindingElements.Find<TransportBindingElement>();
            VerifyTransportQuotas(transport, binding.Name);
        }
开发者ID:ChristianWeyer,项目名称:Thinktecture.ServiceModel,代码行数:19,代码来源:IntranetProfileTests.cs

示例3: GetInnerPropertyIsNothingToDoWithParameters

		public void GetInnerPropertyIsNothingToDoWithParameters ()
		{
			BindingParameterCollection pl =
				new BindingParameterCollection ();
			pl.Add (new ClientCredentials ());
			BindingContext ctx =
				new BindingContext (new CustomBinding (), pl);
			Assert.IsNull (ctx.GetInnerProperty<ClientCredentials> ());

			CustomBinding binding = new CustomBinding (new HttpTransportBindingElement ());
			ctx = new BindingContext (binding, pl);
			Assert.IsNull (ctx.GetInnerProperty<ClientCredentials> ());
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:BindingContextTest.cs


注:本文中的BindingContext.GetInnerProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。