public static IProxyMethodInfo AsProxy(this MethodInfo info)
        {
            IProxyType proxyType = factory.Get(info.DeclaringType);
            Type[] types = info.GetParameterTypes().ToArray();
            if (info.IsPublic)
                return proxyType.GetMethod(info.Name, types);

            return proxyType.GetMethod(info.Name, types, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
        }
        public static IProxyInvoker AsProxy(this MethodInfo info, object target)
        {
            IProxyType       proxyType       = factory.Create(info.DeclaringType);
            IProxyMethodInfo proxyMethodInfo = proxyType.GetMethod(info);

            return(new ProxyInvoker(target, proxyMethodInfo));
        }
Ejemplo n.º 3
0
        public IProxyMethodInfo GetMethod(string name, Type[] parameterTypes, BindingFlags flags)
        {
            IProxyMethodInfo info = this.GetMethodInfo(name, parameterTypes);

            if (info != null)
            {
                return(info);
            }

#if NETFX_CORE
            MethodInfo methodInfo = this.type.GetMethod(name, flags);
#else
            MethodInfo methodInfo = this.type.GetMethod(name, flags, null, parameterTypes, null);
#endif
            if (methodInfo != null && methodInfo.DeclaringType.Equals(type))
            {
                return(this.CreateProxyMethodInfo(methodInfo));
            }

            IProxyType baseTypeInfo = this.GetBase();
            if (baseTypeInfo == null)
            {
                return(null);
            }

            return(baseTypeInfo.GetMethod(name, parameterTypes, flags));
        }
Ejemplo n.º 4
0
        public virtual IProxyMethodInfo GetMethod(string name, Type[] parameterTypes)
        {
            IProxyMethodInfo info = this.GetMethodInfo(name, parameterTypes);

            if (info != null)
            {
                return(info);
            }

            MethodInfo methodInfo = this.type.GetMethod(name, parameterTypes);

            if (methodInfo != null && methodInfo.DeclaringType.Equals(type))
            {
                return(this.CreateProxyMethodInfo(methodInfo));
            }

            IProxyType baseTypeInfo = this.GetBase();

            if (baseTypeInfo == null)
            {
                return(null);
            }

            return(baseTypeInfo.GetMethod(name, parameterTypes));
        }
        public static IProxyMethodInfo AsProxy(this MethodInfo info)
        {
            IProxyType proxyType = factory.Create(info.DeclaringType);

            return(proxyType.GetMethod(info));
        }