Пример #1
0
        /*
         * public CBurlapProxyStandardImpl(Type proxyType, CBurlapProxyFactory burlapProxyFactory, Uri uri, string username, string password)
         *  : base(typeof(IBurlapProxyStandard))
         * {
         *  this.m_proxyType = proxyType;
         *  this.m_methodCaller = new CBurlapMethodCaller(burlapProxyFactory, uri, username, password);
         * }
         */
        #endregion

        /// <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 burlap 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  = CBurlapMethodCaller.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(CBurlapProxy)) ||
                             value.GetType().IsAssignableFrom(typeof(CBurlapProxy)))
                    {
                        objReturnValue = this.m_methodCaller.URI.Equals(((CBurlapProxy)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("GetBurlapURL"))
                {
                    objReturnValue = this.m_methodCaller.URI.ToString();
                }
                else if (methodInfo.Name.Equals("ToString") && argumentTypes.Length == 0)
                {
                    objReturnValue = "[BurlapProxy " + this.m_methodCaller.URI + "]";
                }
                else if (methodInfo.Name.Equals("GetType") && argumentTypes.Length == 0)
                {
                    objReturnValue = this.m_proxyType;
                }
                else
                {
                    objReturnValue = this.m_methodCaller.DoBurlapMethodCall(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));
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="proxyType">Interface type that has to be proxied</param>
 /// <param name="hessianProxyFactory">BurlapProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 public CBurlapProxyStandardImpl(Type proxyType, CBurlapProxyFactory burlapProxyFactory, Uri uri)
     : base(typeof(IBurlapProxyStandard))
 {
     this.m_proxyType = proxyType;
     this.m_methodCaller = new CBurlapMethodCaller(burlapProxyFactory, uri);
 }
Пример #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="burlapProxyFactory">CBurlapProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 internal CBurlapProxy(CBurlapProxyFactory burlapProxyFactory, Uri uri)
 {
     this.m_methodCaller = new CBurlapMethodCaller(burlapProxyFactory, uri);
 }
Пример #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="proxyType">Interface type that has to be proxied</param>
 /// <param name="hessianProxyFactory">BurlapProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 public CBurlapProxyStandardImpl(Type proxyType, CBurlapProxyFactory burlapProxyFactory, Uri uri)
     : base(typeof(IBurlapProxyStandard))
 {
     this.m_proxyType    = proxyType;
     this.m_methodCaller = new CBurlapMethodCaller(burlapProxyFactory, uri);
 }
Пример #5
0
 /// <summary>
 /// Gets method info instance, according to the given method base
 /// </summary>
 /// <param name="methodMessage">Method message, that describes the method call</param>
 /// <returns>MethodInfo - Instance</returns>
 private MethodInfo GetMethodInfoForMethodBase(IMethodCallMessage methodMessage)
 {
     return(this.m_proxyType.GetMethod(methodMessage.MethodName, CBurlapMethodCaller.GetArgTypes(methodMessage.Args)));
 }
Пример #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="burlapProxyFactory">CBurlapProxyFactory - Instance</param>
 /// <param name="uri">Server-Proxy uri</param>
 internal CBurlapProxy(CBurlapProxyFactory burlapProxyFactory, Uri uri)
 {
     this.m_methodCaller = new CBurlapMethodCaller(burlapProxyFactory,uri);
 }