Пример #1
0
        public FAopMethod FindMethod(string name, Type[] types)
        {
            BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            FMethod[] methods = _type.GetAllMethods(flags);
            // Find by types
            foreach (FMethod method in methods)
            {
                if (method.IsMethod(name, types))
                {
                    FAopMethod aopMethod = new FAopMethod();
                    aopMethod.Link(method.Method);
                    return(aopMethod);
                }
            }
            // Find by type length
            foreach (FMethod method in methods)
            {
                if (method.IsName(name) && method.ParameterCount == types.Length)
                {
                    FAopMethod aopMethod = new FAopMethod();
                    aopMethod.Link(method.Method);
                    return(aopMethod);
                }
            }
            return(null);
        }
Пример #2
0
        public void ProcessMethod(FAopComponentBuilder builder, XAopMethod xmethod)
        {
            FAopDescriptor descriptor = builder.Component.Descriptor;

            Type[]     types  = xmethod.GetParameterTypes();
            FAopMethod method = descriptor.FindMethod(xmethod.Method, types);

            if (method == null)
            {
                throw new FFatalException("Config has method. but instance has'nt this method({0}).", xmethod.Method);
            }
            object[] args = BuildParameters(builder, xmethod.Parameters);
            if (_logger.DebugAble)
            {
                _logger.Debug(this, "ProcessMethod", "Call {0}({1})", xmethod.Method, args);
            }
            method.Invoke(builder.Instance, args);
        }