/// <summary> /// Initializes a new instance of the ChannelFactoryEntry class. /// </summary> /// <param name="descriptor">The endpoint descriptor for the cached channel entry.</param> public ChannelFactoryEntry(EndpointDescriptor descriptor) { if (descriptor == null) { throw new ArgumentNullException("descriptor"); } _descriptor = descriptor; _channelFactory = new ChannelFactory <TChannel>(descriptor.Binding, descriptor.EndpointAddress); DataphorServiceUtility.ServiceEndpointHook(_channelFactory.Endpoint); _channelFactory.Open(); }
/// <summary> /// Initializes a new instance of the ChannelFactoryWrapper class. /// </summary> /// <param name="descriptor">The endpoint descriptor for the channel.</param> /// <param name="channelFactory">The channel factory being wrapped.</param> public ChannelFactoryWrapper(EndpointDescriptor descriptor, ChannelFactory <TChannel> channelFactory) { if (descriptor == null) { throw new ArgumentNullException("descriptor"); } if (channelFactory == null) { throw new ArgumentNullException("channelFactory"); } _descriptor = descriptor; _channelFactory = channelFactory; }
/// <summary> /// Gets a channel factory wrapper for the given binding and endpoint address. /// </summary> /// <param name="binding">The binding for the channel factory.</param> /// <param name="endpointAddress">The endpoint address for the channel factory.</param> /// <returns>A channel factory wrapper for a channel factory using the given binding and endpoint address.</returns> public ChannelFactoryWrapper <TChannel> GetChannelFactory(Binding binding, EndpointAddress endpointAddress) { lock (_syncHandle) { var descriptor = new EndpointDescriptor(binding, endpointAddress); ChannelFactoryEntry <TChannel> entry; if (!_cache.TryGetValue(descriptor, out entry)) { entry = new ChannelFactoryEntry <TChannel>(descriptor); _cache.Add(descriptor, entry); } var wrapper = entry.GetChannelFactory(); wrapper.Disposed += new EventHandler(wrapper_Disposed); return(wrapper); } }