Пример #1
0
        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;
            }
        }
Пример #2
0
 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);
 }
Пример #3
0
 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;
             }
         }
     }
 }
Пример #4
0
        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());
        }