public override IMessage Invoke(IMessage msg)
        {
            T t;

            if (this.callBack != null)
            {
                t = DuplexChannelFactoryCreator.Create <T>(this.callBack, this.configurationPath, this.endpointName).CreateChannel();
            }
            else
            {
                t = DuplexChannelFactoryCreator.Create <T>(Activator.CreateInstance(typeof(TCallBack)), this.configurationPath, this.endpointName).CreateChannel();
            }
            IMethodCallMessage   methodCallMessage = (IMethodCallMessage)msg;
            IMethodReturnMessage result            = null;

            object[] array = Array.CreateInstance(typeof(object), methodCallMessage.Args.Length) as object[];
            methodCallMessage.Args.CopyTo(array, 0);
            this.GetParameters(methodCallMessage);
            ServiceProxyFactory.GetEndpointAddress <T>(this.configurationPath, this.endpointName);
            try
            {
                result = new ReturnMessage(methodCallMessage.MethodBase.Invoke(t, array), array, array.Length, methodCallMessage.LogicalCallContext, methodCallMessage);
            }
            catch (CommunicationException e)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e, methodCallMessage);
            }
            catch (TimeoutException e2)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e2, methodCallMessage);
            }
            catch (System.Exception e3)
            {
                (t as ICommunicationObject).Abort();
                result = new ReturnMessage(e3, methodCallMessage);
            }
            return(result);
        }
Exemplo n.º 2
0
 public static string GetEndpointAddress <T, TCallBack>(string configurationPath, string endpointName)
 {
     return(DuplexChannelFactoryCreator.Create <T>(Activator.CreateInstance(typeof(TCallBack)), configurationPath, endpointName).Endpoint.Address.Uri.ToString());
 }