本文整理汇总了C#中System.ServiceModel.NetNamedPipeBinding.InitializeFrom方法的典型用法代码示例。如果您正苦于以下问题:C# NetNamedPipeBinding.InitializeFrom方法的具体用法?C# NetNamedPipeBinding.InitializeFrom怎么用?C# NetNamedPipeBinding.InitializeFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.NetNamedPipeBinding
的用法示例。
在下文中一共展示了NetNamedPipeBinding.InitializeFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryCreate
internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
{
NetNamedPipeSecurity security;
binding = null;
if (elements.Count > 4)
{
return false;
}
TransactionFlowBindingElement context = null;
BinaryMessageEncodingBindingElement encoding = null;
WindowsStreamSecurityBindingElement wssbe = null;
NamedPipeTransportBindingElement namedPipe = null;
foreach (BindingElement element5 in elements)
{
if (element5 is TransactionFlowBindingElement)
{
context = element5 as TransactionFlowBindingElement;
}
else if (element5 is BinaryMessageEncodingBindingElement)
{
encoding = element5 as BinaryMessageEncodingBindingElement;
}
else if (element5 is WindowsStreamSecurityBindingElement)
{
wssbe = element5 as WindowsStreamSecurityBindingElement;
}
else if (element5 is NamedPipeTransportBindingElement)
{
namedPipe = element5 as NamedPipeTransportBindingElement;
}
else
{
return false;
}
}
if (namedPipe == null)
{
return false;
}
if (encoding == null)
{
return false;
}
if (context == null)
{
context = GetDefaultTransactionFlowBindingElement();
}
if (!TryCreateSecurity(wssbe, out security))
{
return false;
}
NetNamedPipeBinding binding2 = new NetNamedPipeBinding(security);
binding2.InitializeFrom(namedPipe, encoding, context);
if (!binding2.IsBindingElementsMatch(namedPipe, encoding, context))
{
return false;
}
binding = binding2;
return true;
}
示例2: TryCreate
internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
{
binding = null;
if (elements.Count > 4)
return false;
TransactionFlowBindingElement context = null;
BinaryMessageEncodingBindingElement encoding = null;
WindowsStreamSecurityBindingElement security = null;
NamedPipeTransportBindingElement namedPipe = null;
foreach (BindingElement element in elements)
{
if (element is TransactionFlowBindingElement)
context = element as TransactionFlowBindingElement;
else if (element is BinaryMessageEncodingBindingElement)
encoding = element as BinaryMessageEncodingBindingElement;
else if (element is WindowsStreamSecurityBindingElement)
security = element as WindowsStreamSecurityBindingElement;
else if (element is NamedPipeTransportBindingElement)
namedPipe = element as NamedPipeTransportBindingElement;
else
return false;
}
if (namedPipe == null)
return false;
if (encoding == null)
return false;
if (context == null)
context = GetDefaultTransactionFlowBindingElement();
NetNamedPipeSecurity pipeSecurity;
if (!TryCreateSecurity(security, out pipeSecurity))
return false;
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding(pipeSecurity);
netNamedPipeBinding.InitializeFrom(namedPipe, encoding, context);
if (!netNamedPipeBinding.IsBindingElementsMatch(namedPipe, encoding, context))
return false;
binding = netNamedPipeBinding;
return true;
}