Esempio n. 1
0
        IAction IAction.Init(MethodWrapper methodWrapper, IAction nextAction)
        {
            Proxy = methodWrapper;
            NextAction = nextAction;

            Config();

            return this;
        }
Esempio n. 2
0
File: Test1.cs Progetto: xqgzh/zata
        public static void TestPerf()
        {
            //这次测试中文1234
            Stopwatch sw = new Stopwatch();

            int MaxTimes = 100;
            TT t = new TT();
            MethodInfo mi = t.GetType().GetMethod("Test");
            MethodWrapper invoker = new MethodWrapper(t.GetType().GetCustomAttributes(false), true, () => { return new TT(); }, t, mi, mi.GetCustomAttributes(false));

            ActionBuilder builder = new ActionBuilder();
            builder.RegistType<TT>();

            IAction action = builder.FindAction("TT.Test");

            ActionContext context = new ActionContext()
            {
                Arguments = new object[] { "1", "2" },
                oInstance = t
            };

            Test(5, MaxTimes,
                (i, w) => {
                    string s = string.Empty;

                    switch (i)
                    {
                        case 0:
                            s = "方法直接调用";
                            break;
                        case 1:
                            s = "动态代理方法调用";
                            break;
                        case 2:
                            s = "Zata封装方法调用";
                            break;
                        case 3:
                            s = "反射调用";
                            break;
                    }

                    Console.WriteLine("{0}: {1}毫秒",s, w.ElapsedMilliseconds); },
                i => { t.Test("1", "2"); },
                i => invoker.Execute(context),
                i => { action.Execute(context); },
                i => mi.Invoke(t, new object[] { "1", "2"})
                );
        }
Esempio n. 3
0
        public virtual IAction Init(MethodWrapper methodWrapper, IAction nextAction)
        {
            Proxy = methodWrapper;

            NextAction = nextAction;

            #region 构造缓存键

            CacheKeyFormater += methodWrapper.methodInfo.Name;

            ParamInfo[] paras = methodWrapper.Parameters;

            for (int i = 0, j = paras.Length; i < j; i++)
            {
                if (CachedKeyAttribute.IsDefined(paras[i].ParameterInfo, typeof(CachedKeyAttribute)))
                {
                    CacheKeyFormater += "_{" + i + "}";
                }
            }

            #endregion

            return this;
        }