Ejemplo n.º 1
0
        /// <summary>
        /// Helper method to create the right binding depending on the configuration element
        /// </summary>
        /// <param name="configurationElement"></param>
        /// <returns></returns>
        protected virtual Binding GetBinding(IBindingConfigurationElement configurationElement)
        {
            IDictionary <Type, Binding> container = new Dictionary <Type, Binding>
            {
                { typeof(CustomBindingElement), new CustomBinding() }, { typeof(BasicHttpBindingElement), new BasicHttpBinding() },
                { typeof(NetMsmqBindingElement), new NetMsmqBinding() }, { typeof(NetNamedPipeBindingElement), new NetNamedPipeBinding() },
                { typeof(NetPeerTcpBindingElement), new NetPeerTcpBinding() }, { typeof(NetTcpBindingElement), new NetTcpBinding() },
                { typeof(WSDualHttpBindingElement), new WSDualHttpBinding() }, { typeof(WSHttpBindingElement), new WSHttpBinding() },
                { typeof(WSFederationHttpBindingElement), new WSFederationHttpBinding() }
            };

            return(container.ContainsKey(configurationElement.GetType()) ? container[configurationElement.GetType()] : null);
        }
        private Binding GetBinding(IBindingConfigurationElement bindingElement)
        {
            Type    type    = bindingElement.GetType();
            Binding binding = null;

            if (type == typeof(BasicHttpBindingElement))
            {
                binding = new BasicHttpBinding();
            }
            if (type == typeof(WSHttpBindingElement))
            {
                binding = new WSHttpBinding();
            }

            if (type == typeof(NetTcpBindingElement))
            {
                binding = new NetTcpBinding();
            }

            if (type == typeof(NetNamedPipeBindingElement))
            {
                binding = new NetNamedPipeBinding();
            }

            //bug...
            bindingElement.ApplyConfiguration(binding);
            return(binding);
        }
Ejemplo n.º 3
0
        public static string GetBindingName(IBindingConfigurationElement bindingElement)
        {
            var bindingElementDecorator = bindingElement as IBindingElementDecorator;
            var bindingType             = bindingElementDecorator == null
                                ? bindingElement.GetType()
                                : bindingElementDecorator.DecoratedBindingElement.GetType();

            return(_instance[bindingType]);
        }
Ejemplo n.º 4
0
        public static string GetBindingName(IBindingConfigurationElement bindingElement)
        {
            if (bindingElement == null)
            {
                throw new ArgumentNullException(nameof(bindingElement));
            }
            var bindingType = bindingElement is IBindingElementDecorator bindingElementDecorator
                                ? bindingElementDecorator.DecoratedBindingElement.GetType()
                                : bindingElement.GetType();

            return(_instance[bindingType]);
        }