Ejemplo n.º 1
0
        internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }
            binding = null;
            ContextBindingElement element = bindingElements.Find <ContextBindingElement>();

            if (element != null)
            {
                Binding binding2;
                BindingElementCollection elements = new BindingElementCollection(bindingElements);
                elements.Remove <ContextBindingElement>();
                if (WSHttpBindingBase.TryCreate(elements, out binding2))
                {
                    bool allowCookies = ((WSHttpBinding)binding2).AllowCookies;
                    if ((allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie)) || (!allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader)))
                    {
                        WSHttpContextBinding binding3 = new WSHttpContextBinding((WSHttpBinding)binding2)
                        {
                            ContextProtectionLevel   = element.ProtectionLevel,
                            ContextManagementEnabled = element.ContextManagementEnabled
                        };
                        binding = binding3;
                    }
                }
            }
            return(binding != null);
        }
        internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }

            binding = null;

            ContextBindingElement contextBindingElement = bindingElements.Find <ContextBindingElement>();

            if (contextBindingElement != null)
            {
                BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements);
                bindingElementsWithoutContext.Remove <ContextBindingElement>();
                Binding wsHttpBinding;
                if (WSHttpBinding.TryCreate(bindingElementsWithoutContext, out wsHttpBinding))
                {
                    bool allowCookies = ((WSHttpBinding)wsHttpBinding).AllowCookies;
                    if (allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie ||
                        !allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader)
                    {
                        WSHttpContextBinding contextBinding = new WSHttpContextBinding((WSHttpBinding)wsHttpBinding);
                        contextBinding.ContextProtectionLevel   = contextBindingElement.ProtectionLevel;
                        contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled;
                        binding = contextBinding;
                    }
                }
            }

            return(binding != null);
        }
 public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext)
 {
     System.ServiceModel.Channels.Binding binding;
     if (endpointContext == null)
     {
         throw new ArgumentNullException("endpointContext");
     }
     if (endpointContext.Endpoint.Binding == null)
     {
         throw new ArgumentNullException("endpointContext.Binding");
     }
     if (endpointContext.Endpoint.Binding is CustomBinding)
     {
         BindingElementCollection elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements;
         if (elements.Find <HttpRelayTransportBindingElement>() != null)
         {
             elements.Remove <HttpsTransportBindingElement>();
             if (WSHttpRelayBindingBase.TryCreate(elements, out binding))
             {
                 StandardRelayBindingImporter.SetBinding(endpointContext.Endpoint, binding);
                 return;
             }
             if (BasicHttpRelayBinding.TryCreate(elements, out binding))
             {
                 StandardRelayBindingImporter.SetBinding(endpointContext.Endpoint, binding);
                 return;
             }
         }
         else if (elements.Find <TcpRelayTransportBindingElement>() != null && NetTcpRelayBinding.TryCreate(elements, out binding))
         {
             StandardRelayBindingImporter.SetBinding(endpointContext.Endpoint, binding);
         }
     }
 }
Ejemplo n.º 4
0
        internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }
            binding = null;
            ContextBindingElement element = bindingElements.Find <ContextBindingElement>();

            if ((element != null) && (element.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie))
            {
                Binding binding2;
                BindingElementCollection elements = new BindingElementCollection(bindingElements);
                elements.Remove <ContextBindingElement>();
                if (NetTcpBinding.TryCreate(elements, out binding2))
                {
                    NetTcpContextBinding binding3 = new NetTcpContextBinding((NetTcpBinding)binding2)
                    {
                        ContextProtectionLevel   = element.ProtectionLevel,
                        ContextManagementEnabled = element.ContextManagementEnabled
                    };
                    binding = binding3;
                }
            }
            return(binding != null);
        }
        internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }

            binding = null;

            ContextBindingElement contextBindingElement = bindingElements.Find <ContextBindingElement>();

            if (contextBindingElement != null && contextBindingElement.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie)
            {
                BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements);
                bindingElementsWithoutContext.Remove <ContextBindingElement>();
                Binding netTcpBinding;
                if (NetTcpBinding.TryCreate(bindingElementsWithoutContext, out netTcpBinding))
                {
                    NetTcpContextBinding contextBinding = new NetTcpContextBinding((NetTcpBinding)netTcpBinding);
                    contextBinding.ContextProtectionLevel   = contextBindingElement.ProtectionLevel;
                    contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled;
                    binding = contextBinding;
                }
            }

            return(binding != null);
        }
 internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
 {
     if (bindingElements == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
     }
     binding = null;
     ContextBindingElement element = bindingElements.Find<ContextBindingElement>();
     if ((element != null) && (element.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie))
     {
         Binding binding2;
         BindingElementCollection elements = new BindingElementCollection(bindingElements);
         elements.Remove<ContextBindingElement>();
         if (NetTcpBinding.TryCreate(elements, out binding2))
         {
             NetTcpContextBinding binding3 = new NetTcpContextBinding((NetTcpBinding) binding2) {
                 ContextProtectionLevel = element.ProtectionLevel,
                 ContextManagementEnabled = element.ContextManagementEnabled
             };
             binding = binding3;
         }
     }
     return (binding != null);
 }
        internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }

            binding = null;

            ContextBindingElement contextBindingElement = bindingElements.Find<ContextBindingElement>();
            if (contextBindingElement != null)
            {
                BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements);
                bindingElementsWithoutContext.Remove<ContextBindingElement>();
                Binding wsHttpBinding;
                if (WSHttpBinding.TryCreate(bindingElementsWithoutContext, out wsHttpBinding))
                {
                    bool allowCookies = ((WSHttpBinding)wsHttpBinding).AllowCookies;
                    if (allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie
                        || !allowCookies && contextBindingElement.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader)
                    {
                        WSHttpContextBinding contextBinding = new WSHttpContextBinding((WSHttpBinding)wsHttpBinding);
                        contextBinding.ContextProtectionLevel = contextBindingElement.ProtectionLevel;
                        contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled;
                        binding = contextBinding;
                    }
                }
            }

            return binding != null;
        }
 internal static bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
 {
     if (bindingElements == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
     }
     binding = null;
     ContextBindingElement element = bindingElements.Find<ContextBindingElement>();
     if (element != null)
     {
         Binding binding2;
         BindingElementCollection elements = new BindingElementCollection(bindingElements);
         elements.Remove<ContextBindingElement>();
         if (WSHttpBindingBase.TryCreate(elements, out binding2))
         {
             bool allowCookies = ((WSHttpBinding) binding2).AllowCookies;
             if ((allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.HttpCookie)) || (!allowCookies && (element.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader)))
             {
                 WSHttpContextBinding binding3 = new WSHttpContextBinding((WSHttpBinding) binding2) {
                     ContextProtectionLevel = element.ProtectionLevel,
                     ContextManagementEnabled = element.ContextManagementEnabled
                 };
                 binding = binding3;
             }
         }
     }
     return (binding != null);
 }
        internal static new bool TryCreate(BindingElementCollection bindingElements, out Binding binding)
        {
            if (bindingElements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements");
            }

            binding = null;

            ContextBindingElement contextBindingElement = bindingElements.Find<ContextBindingElement>();
            if (contextBindingElement != null && contextBindingElement.ContextExchangeMechanism != ContextExchangeMechanism.HttpCookie)
            {
                BindingElementCollection bindingElementsWithoutContext = new BindingElementCollection(bindingElements);
                bindingElementsWithoutContext.Remove<ContextBindingElement>();
                Binding netTcpBinding;
                if (NetTcpBinding.TryCreate(bindingElementsWithoutContext, out netTcpBinding))
                {
                    NetTcpContextBinding contextBinding = new NetTcpContextBinding((NetTcpBinding)netTcpBinding);
                    contextBinding.ContextProtectionLevel = contextBindingElement.ProtectionLevel;
                    contextBinding.ContextManagementEnabled = contextBindingElement.ContextManagementEnabled;
                    binding = contextBinding;
                }
            }

            return binding != null;
        }