void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext)
        {
            if (endpointContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext");
            }

#pragma warning suppress 56506 // [....], endpointContext.Endpoint is never null
            if (endpointContext.Endpoint.Binding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding");
            }

            if (endpointContext.Endpoint.Binding is CustomBinding)
            {
                BindingElementCollection elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements;

                Binding binding;
                TransportBindingElement transport = elements.Find <TransportBindingElement>();

                if (transport is HttpTransportBindingElement)
                {
                    if (WSHttpBindingBase.TryCreate(elements, out binding))
                    {
                        SetBinding(endpointContext.Endpoint, binding);
                    }
                    else if (WSDualHttpBinding.TryCreate(elements, out binding))
                    {
                        SetBinding(endpointContext.Endpoint, binding);
                    }
                    else if (BasicHttpBinding.TryCreate(elements, out binding))
                    {
                        SetBinding(endpointContext.Endpoint, binding);
                    }
                    else if (NetHttpBinding.TryCreate(elements, out binding))
                    {
                        SetBinding(endpointContext.Endpoint, binding);
                    }
                }
                else if (transport is MsmqTransportBindingElement && NetMsmqBinding.TryCreate(elements, out binding))
                {
                    SetBinding(endpointContext.Endpoint, binding);
                }
                else if (transport is NamedPipeTransportBindingElement && NetNamedPipeBinding.TryCreate(elements, out binding))
                {
                    SetBinding(endpointContext.Endpoint, binding);
                }
#pragma warning disable 0618
                else if (transport is PeerTransportBindingElement && NetPeerTcpBinding.TryCreate(elements, out binding))
                {
                    SetBinding(endpointContext.Endpoint, binding);
                }
#pragma warning restore 0618
                else if (transport is TcpTransportBindingElement && NetTcpBinding.TryCreate(elements, out binding))
                {
                    SetBinding(endpointContext.Endpoint, binding);
                }
            }
        }
示例#2
0
 void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext)
 {
     if (endpointContext == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext");
     }
     if (endpointContext.Endpoint.Binding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding");
     }
     if (endpointContext.Endpoint.Binding is CustomBinding)
     {
         System.ServiceModel.Channels.Binding binding;
         BindingElementCollection             elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements;
         TransportBindingElement element = elements.Find <TransportBindingElement>();
         if (element is HttpTransportBindingElement)
         {
             if (WSHttpBindingBase.TryCreate(elements, out binding))
             {
                 this.SetBinding(endpointContext.Endpoint, binding);
             }
             else if (WSDualHttpBinding.TryCreate(elements, out binding))
             {
                 this.SetBinding(endpointContext.Endpoint, binding);
             }
             else if (BasicHttpBinding.TryCreate(elements, out binding))
             {
                 this.SetBinding(endpointContext.Endpoint, binding);
             }
         }
         else if ((element is MsmqTransportBindingElement) && NetMsmqBinding.TryCreate(elements, out binding))
         {
             this.SetBinding(endpointContext.Endpoint, binding);
         }
         else if ((element is NamedPipeTransportBindingElement) && NetNamedPipeBinding.TryCreate(elements, out binding))
         {
             this.SetBinding(endpointContext.Endpoint, binding);
         }
         else if ((element is PeerTransportBindingElement) && NetPeerTcpBinding.TryCreate(elements, out binding))
         {
             this.SetBinding(endpointContext.Endpoint, binding);
         }
         else if ((element is TcpTransportBindingElement) && NetTcpBinding.TryCreate(elements, out binding))
         {
             this.SetBinding(endpointContext.Endpoint, binding);
         }
     }
 }