internal static TransientChannelTicket CreateTransientChannel(LogicalChannel logicalChannel) { DiagnosticUtility.DebugAssert(logicalChannel != null, "logical channel cannot be null"); ChannelFactory factory = null; IChannel channel = null; bool channelOpened = false; try { factory = ChannelManagerHelpers.CreateChannelFactory(logicalChannel.ConfigurationName, logicalChannel.ContractType); channel = ChannelManagerHelpers.CreateChannel(logicalChannel.ContractType, factory, logicalChannel.CustomAddress); channelOpened = true; } finally { if (!channelOpened) { if (channel != null) { ChannelManagerHelpers.CloseCommunicationObject(channel); } if (factory != null) { ChannelManagerHelpers.CloseCommunicationObject(factory); } } } return(new TransientChannelTicket(channel, factory)); }
ChannelFactoryReference CreateChannelFactory(EndpointAddress address) { KeyValuePair <string, Type> endpointData; if (this.endpointMappings.ContainsKey(address)) { endpointData = (KeyValuePair <string, Type>) this.endpointMappings[address]; if (endpointMappings != null) { return(new ChannelFactoryReference( ChannelManagerHelpers.CreateChannelFactory(endpointData.Key, endpointData.Value, this.endpoints), endpointData.Value)); } } return(null); }