本文整理汇总了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;
}
示例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);
}
示例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> ());
}