Example #1
0
        /// <summary>
        /// Constructs a channel factory from a <see cref="WcfEndpoint" />.
        /// </summary>
        /// <param name="endpoint">The <see cref="WcfEndpoint" /> describing the service endpoint.</param>
        public WcfChannelFactory(WcfEndpoint endpoint)
        {
            Binding         binding;
            EndpointAddress address;

            binding = endpoint.Binding;
            address = new EndpointAddress(endpoint.Uri);
            factory = new ChannelFactory <TChannel>(binding, address);
            factory.Open();
        }
Example #2
0
        /// <summary>
        /// Exposes a service endpoint for the specified service interface type.
        /// </summary>
        /// <param name="interfaceType">The interface type.</param>
        /// <param name="endpoint">The WCF endpoint.</param>
        /// <remarks>
        /// <note>
        /// This method cannot be called after the service has started.
        /// </note>
        /// </remarks>
        /// <exception cref="InvalidOperationException">Thrown if the service has already started or the interface is not tagged with [ServiceContract].</exception>
        public void AddServiceEndpoint(System.Type interfaceType, WcfEndpoint endpoint)
        {
            if (isRunning)
            {
                throw new InvalidOperationException("AddServiceEndpoint() cannot be called after the service has started.");
            }

            if (Helper.GetCustomAttribute(interfaceType, typeof(ServiceContractAttribute), true) == null)
            {
                throw new ArgumentException(string.Format("Service interface [{0}] is not tagged with [ServiceContract].", interfaceType.FullName));
            }

            host.AddServiceEndpoint(interfaceType, endpoint.Binding, endpoint.Uri);
        }
Example #3
0
        /// <summary>
        /// Parses an array of <see cref="WcfEndpoint" /> instances from a configuration
        /// setting array.
        /// </summary>
        /// <param name="config">The configuration settings.</param>
        /// <param name="key">The base setting key name.</param>
        /// <returns>The array of endpoints.</returns>
        /// /// <exception cref="ArgumentException">Thrown if any of the endpoints are not properly formatted.</exception>
        public static WcfEndpoint[] LoadConfigArray(Config config, string key)
        {
            WcfEndpoint[] endpoints;
            string[]      input;

            input     = config.GetArray(key);
            endpoints = new WcfEndpoint[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                endpoints[i] = Parse(input[i]);
            }

            return(endpoints);
        }
Example #4
0
 /// <summary>
 /// Constructs a channel factory from the textual description of a <see cref="WcfEndpoint" />.
 /// </summary>
 /// <param name="endpointSettings">The textual description of a <see cref="WcfEndpoint" />.</param>
 public WcfChannelFactory(string endpointSettings)
     : this(WcfEndpoint.Parse(endpointSettings))
 {
 }
Example #5
0
 /// <summary>
 /// Exposes a service endpoint for the specified service interface type.
 /// </summary>
 /// <param name="interfaceType">The interface type.</param>
 /// <param name="endpoint">The WCF endpoint as a string.</param>
 /// <remarks>
 /// <note>
 /// This method cannot be called after the service has started.
 /// </note>
 /// </remarks>
 /// <exception cref="InvalidOperationException">Thrown if the service has already started or the interface is not tagged with [ServiceContract].</exception>
 public void AddServiceEndpoint(System.Type interfaceType, string endpoint)
 {
     AddServiceEndpoint(interfaceType, WcfEndpoint.Parse(endpoint));
 }