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


C# NetNamedPipeBinding.InitializeFrom方法代码示例

本文整理汇总了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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:NetNamedPipeBinding.cs

示例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;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:47,代码来源:NetNamedPipeBinding.cs


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