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


C# NetTcpBinding.IsBindingElementsMatch方法代码示例

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


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

示例1: TryCreate

        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            binding = null;
            if (elements.Count > 6)
                return false;

            // collect all binding elements
            TcpTransportBindingElement transport = null;
            BinaryMessageEncodingBindingElement encoding = null;

            SecurityBindingElement wsSecurity = null;
            BindingElement transportSecurity = null;

            foreach (BindingElement element in elements)
            {
                if (element is SecurityBindingElement)
                    wsSecurity = element as SecurityBindingElement;
                else if (element is TransportBindingElement)
                    transport = element as TcpTransportBindingElement;
                else if (element is MessageEncodingBindingElement)
                    encoding = element as BinaryMessageEncodingBindingElement;
                else
                {
                    if (transportSecurity != null)
                        return false;
                    transportSecurity = element;
                }
            }

            if (transport == null)
                return false;
            if (encoding == null)
                return false;

            TcpTransportSecurity tcpTransportSecurity = new TcpTransportSecurity();
            UnifiedSecurityMode mode = GetModeFromTransportSecurity(transportSecurity);

            NetTcpSecurity security;
            if (!TryCreateSecurity(wsSecurity, mode, false /*session != null*/, transportSecurity, tcpTransportSecurity, out security))
                return false;

            if (!SetTransportSecurity(transportSecurity, security.Mode, tcpTransportSecurity))
                return false;

            NetTcpBinding netTcpBinding = new NetTcpBinding(transport, encoding, security);
            if (!netTcpBinding.IsBindingElementsMatch(transport, encoding))
                return false;

            binding = netTcpBinding;
            return true;
        }
开发者ID:shijiaxing,项目名称:wcf,代码行数:51,代码来源:NetTcpBinding.cs

示例2: TryCreate

 internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
 {
     NetTcpSecurity security2;
     binding = null;
     if (elements.Count > 6)
     {
         return false;
     }
     TcpTransportBindingElement transport = null;
     BinaryMessageEncodingBindingElement encoding = null;
     TransactionFlowBindingElement context = null;
     ReliableSessionBindingElement session = null;
     SecurityBindingElement sbe = null;
     BindingElement element6 = null;
     foreach (BindingElement element7 in elements)
     {
         if (element7 is SecurityBindingElement)
         {
             sbe = element7 as SecurityBindingElement;
         }
         else if (element7 is TransportBindingElement)
         {
             transport = element7 as TcpTransportBindingElement;
         }
         else if (element7 is MessageEncodingBindingElement)
         {
             encoding = element7 as BinaryMessageEncodingBindingElement;
         }
         else if (element7 is TransactionFlowBindingElement)
         {
             context = element7 as TransactionFlowBindingElement;
         }
         else if (element7 is ReliableSessionBindingElement)
         {
             session = element7 as ReliableSessionBindingElement;
         }
         else
         {
             if (element6 != null)
             {
                 return false;
             }
             element6 = element7;
         }
     }
     if (transport == null)
     {
         return false;
     }
     if (encoding == null)
     {
         return false;
     }
     if (context == null)
     {
         context = GetDefaultTransactionFlowBindingElement();
     }
     TcpTransportSecurity tcpTransportSecurity = new TcpTransportSecurity();
     UnifiedSecurityMode modeFromTransportSecurity = GetModeFromTransportSecurity(element6);
     if (!TryCreateSecurity(sbe, modeFromTransportSecurity, session != null, element6, tcpTransportSecurity, out security2))
     {
         return false;
     }
     if (!SetTransportSecurity(element6, security2.Mode, tcpTransportSecurity))
     {
         return false;
     }
     NetTcpBinding binding2 = new NetTcpBinding(transport, encoding, context, session, security2);
     if (!binding2.IsBindingElementsMatch(transport, encoding, context, session))
     {
         return false;
     }
     binding = binding2;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:75,代码来源:NetTcpBinding.cs


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