Ejemplo n.º 1
0
        /// <summary>
        /// Create a client proxy that does not need configuration.  Uses default parameters and BasicHttpBinding
        /// </summary>
        /// <typeparam name="I">Interface service contract that this connection will use</typeparam>
        /// <param name="uri">Host of service including any ports or paths URLs</param>
        /// <returns>Open client</returns>
        public static I Create <I>(string uri)
        {
            var ep = new WcfEndPoint()
            {
                EndPointAddressUrl      = uri,
                Binding                 = WcfBindings.BasicHttp,
                ServiceContractTypeName = typeof(I).AssemblyQualifiedName
            };

            return(Create <I>(ep));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a client proxy that uses an &lt;endpoint&gt; configuration section.
        /// </summary>
        /// <typeparam name="I">Interface of service contract that this connection will use</typeparam>
        /// <param name="uri">Host URL of service including any ports and paths</param>
        /// <param name="endPointConfigurationName">Name of end point configuration. NOTE: These parameters are in reverse of ChannelFactory constructor</param>
        /// <returns>Newly created open client</returns>
        public static I Create <I>(string uri, string endPointConfigurationName)
        {
            var ep = new WcfEndPoint()
            {
                EndPointAddressUrl      = uri,
                ServiceContractTypeName = typeof(I).AssemblyQualifiedName,
                ConfigurationName       = endPointConfigurationName
            };

            return(Create <I>(ep));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new instance of a channel for a particular service interface
        /// </summary>
        /// <typeparam name="I">Service interface that is being instantiated</typeparam>
        /// <param name="ep">Hyrdrated paraemters to use while building client proxy</param>
        /// <returns>Client proxy to WCF service end point ready to be used by application</returns>
        public static I Create <I>(WcfEndPoint ep)
        {
            if (ep.Binding != WcfBindings.Direct)
            {
                Binding         myBinding  = ep.GetBinding();
                EndpointAddress myEndpoint = ep.WcfAddress;
                return(new ChannelFactory <I>(myBinding, myEndpoint).CreateChannel());
            }

            return(ProviderFactory <I> .GetInstance(ep.ProxyAddress));
        }