コード例 #1
0
        /// <summary>
        /// This reflective method for invoking methods. Overriden from RealProxy.
        /// Handles the object invocation. This method wrapps an instance call to the hessian
        /// requests, sends it to the hessian service and translates the reply of this call to the C# - data type
        /// <see cref="System.Runtime.Remoting.Proxies.RealProxy"/>
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override IMessage Invoke(IMessage msg)
        {
            // Convert to a MethodCallMessage
            IMethodCallMessage methodMessage = new MethodCallMessageWrapper((IMethodCallMessage)msg);
            MethodInfo         methodInfo    = this.GetMethodInfoForMethodBase(methodMessage);

            Type[] argumentTypes  = CHessianMethodCaller.GetArgTypes(methodMessage.Args);
            object objReturnValue = null;

            if (methodInfo != null)
            {
                if (methodInfo.Name.Equals("Equals") && argumentTypes != null &&
                    argumentTypes.Length == 1 && argumentTypes[0].IsAssignableFrom((typeof(Object))))
                {
                    Object value = methodMessage.Args[0];
                    if (value == null)
                    {
                        objReturnValue = false;
                    }
                    else if (value.GetType().Equals(typeof(CHessianProxy)) ||
                             value.GetType().IsAssignableFrom(typeof(CHessianProxy)))
                    {
                        objReturnValue = this.m_methodCaller.URI.Equals(((CHessianProxy)value).URI);
                    }
                    else
                    {
                        objReturnValue = false;
                    }
                }
                else if (methodInfo.Name.Equals("GetHashCode") && argumentTypes.Length == 0)
                {
                    objReturnValue = this.m_methodCaller.URI.GetHashCode();
                }
                else if (methodInfo.Name.Equals("GetHessianURL"))
                {
                    objReturnValue = this.m_methodCaller.URI.ToString();
                }
                else if (methodInfo.Name.Equals("ToString") && argumentTypes.Length == 0)
                {
                    objReturnValue = "[HessianProxy " + this.m_methodCaller.URI + "]";
                }
                else if (methodInfo.Name.Equals("GetType") && argumentTypes.Length == 0)
                {
                    objReturnValue = this.m_proxyType;
                }
                else
                {
                    objReturnValue = this.m_methodCaller.DoHessianMethodCall(methodMessage.Args, methodInfo);
                }
            }
            else
            {
                if (methodMessage.MethodName.Equals("GetType") && (methodMessage.ArgCount == 0))
                {
                    objReturnValue = this.m_proxyType;
                }
            }
            // Create the return message (ReturnMessage)
            return(new ReturnMessage(objReturnValue, methodMessage.Args, methodMessage.ArgCount, methodMessage.LogicalCallContext, methodMessage));
        }
コード例 #2
0
 public CHessianProxyStandardImpl(Type proxyType, CHessianProxyFactory hessianProxyFactory, Uri uri, string username, string password)
     : base(typeof(IHessianProxyStandard))
 {
     this.m_proxyType    = proxyType;
     this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri, username, password);
 }
コード例 #3
0
 internal CHessianProxy(CHessianProxyFactory hessianProxyFactory, Uri uri, string username, string password)
 {
     this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri, username, password);
 }
コード例 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="proxyType">Interface type that has to be proxied</param>
 /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 public CHessianProxyStandardImpl(Type proxyType, CHessianProxyFactory hessianProxyFactory, Uri uri)
     : base(typeof(IHessianProxyStandard))
 {
     this.m_proxyType    = proxyType;
     this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri);
 }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="hessianProxyFactory">HessianProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 internal CHessianProxy(CHessianProxyFactory hessianProxyFactory, Uri uri)
 {
     this.m_methodCaller = new CHessianMethodCaller(hessianProxyFactory, uri);
 }