public virtual void Execute(ActionContext Context) { if (NextAction != null) NextAction.Execute(Context); else if (Proxy != null) Proxy.Execute(Context); }
public virtual void Execute(ActionContext Context) { HttpActionContext context = Context as HttpActionContext; if (context != null && context.IsCached == false) { //缓存未命中, 需要执行 NextAction.Execute(Context); } }
public HttpActionContext(ActionContext context) : base(context) { HttpActionContext thisContext = context as HttpActionContext; if (thisContext != null) { ResponseWrapper = thisContext.ResponseWrapper; } }
public override void Execute(ActionContext Context) { string CacheKey = string.Format(CacheKeyFormater, Context.Arguments); Context.Result = cacheManager.Get(CacheKey); if (Context.Result == null) { base.Execute(Context); DateTime CurrentTime = DateTime.Now; cacheManager.Add( CacheKey, Context.Result, null, DateTime.Now.AddSeconds(DefaultExpireSeconds), TimeSpan.Zero, CacheItemPriority.Default, null); } }
public override void Execute(ActionContext Context) { Context.Arguments = PrepareParameters(Context.Arguments); base.Execute(Context); }
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"}) ); }
/// <summary> /// 调用业务方法 /// </summary> /// <param name="Context"></param> /// <returns></returns> public ActionContext Execute(ActionContext Context) { object o = Context.oInstance ?? ((IsCreateIfRequest && CreateInstance != null) ? CreateInstance() : GlobalInstance); if (methodInfo.IsStatic == false && o == null) { throw new System.Configuration.ConfigurationErrorsException(methodInfo.Name + "方法必须运行于实例之中"); } Context.Result = Executer(o, Context.Arguments); return Context; }
public ActionContext(ActionContext context) { oInstance = context.oInstance; Arguments = context.Arguments; Result = context.Result; }