public ClientRuntimeChannel(ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, EndpointAddress remoteAddress, Uri via) { this.runtime = runtime; this.remote_address = remoteAddress; runtime.Via = via; this.contract = contract; this.message_version = messageVersion; default_open_timeout = openTimeout; default_close_timeout = closeTimeout; _processDelegate = new ProcessDelegate(Process); requestDelegate = new RequestDelegate(Request); sendDelegate = new SendDelegate(Send); // default values AllowInitializationUI = true; OperationTimeout = TimeSpan.FromMinutes(1); if (contextChannel != null) { channel = contextChannel; } else { var method = factory.GetType().GetMethod("CreateChannel", new Type [] { typeof(EndpointAddress), typeof(Uri) }); channel = (IChannel)method.Invoke(factory, new object [] { remote_address, Via }); this.factory = factory; } }
public object CreateChannel() { // create transparent proxy base.EnsureOpened(); object[] objArray = new object[] { _channelType, base.Endpoint.Address, null }; _tp = _factory.GetType().InvokeMember("CreateChannel", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, _factory, objArray, CultureInfo.InvariantCulture); return(_tp); }
public ClientRuntimeChannel(System.ServiceModel.Dispatcher.ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, System.ServiceModel.EndpointAddress remoteAddress, Uri via) { if (runtime == null) { throw new ArgumentNullException("runtime"); } if (messageVersion == null) { throw new ArgumentNullException("messageVersion"); } this.runtime = runtime; this.remote_address = remoteAddress; if (runtime.Via == null) { runtime.Via = via ?? (remote_address != null ? remote_address.Uri : null); } this.contract = contract; this.message_version = messageVersion; default_open_timeout = openTimeout; default_close_timeout = closeTimeout; _processDelegate = new ProcessDelegate(Process); requestDelegate = new RequestDelegate(Request); sendDelegate = new SendDelegate(Send); AllowInitializationUI = true; if (contextChannel != null) { channel = contextChannel; } else { var method = factory.GetType().GetMethod("CreateChannel", new Type[] { typeof(System.ServiceModel.EndpointAddress), typeof(Uri) }); try { channel = (IChannel)method.Invoke(factory, new object[] { remote_address, Via }); this.factory = factory; } catch (System.Reflection.TargetInvocationException ex) { if (ex.InnerException != null) { throw ex.InnerException; } else { throw; } } } }
public T CreateServiceFromFactory <T>(IChannelFactory <T> channelFactory) where T : class { var concreteChannelFactory = channelFactory as ChannelFactory <T>; if (concreteChannelFactory != null) { return(concreteChannelFactory.CreateChannel()); } throw new InvalidOperationException("Invalid IChannelFactory type: " + channelFactory.GetType()); }