Пример #1
0
        //---------------------------------------------------------------------------------------------------------


        private static Dictionary <String, ActionCache> loadActionCacheAttrs()
        {
            Dictionary <String, ActionCache> results = new Dictionary <String, ActionCache>();

            Dictionary <String, ControllerMeta> metas = ControllerMeta.GetMetaDB();

            foreach (KeyValuePair <String, ControllerMeta> kv in metas)
            {
                ControllerMeta controller = kv.Value;

                foreach (KeyValuePair <String, ControllerAction> caKv in controller.ActionMaps)
                {
                    ControllerAction action = caKv.Value;

                    foreach (Attribute a in action.AttributeList)
                    {
                        CacheActionAttribute attrCache = a as CacheActionAttribute;
                        if (attrCache == null)
                        {
                            continue;
                        }

                        ActionCache obj = (ActionCache)ObjectContext.GetByType(attrCache.ActionCacheType);

                        results.Add(controller.ControllerType.FullName + "_" + action.ActionName, obj);
                    }
                }
            }

            return(results);
        }
Пример #2
0
        //----------------------------------------------------------------------
        private void initCacheKey( ActionCache actionCache, MvcContext ctx )
        {
            if (actionCache == null) return;

            // 只在 GET 下缓存
            if (ctx.HttpMethod.Equals( "GET" ) == false) return;

            _cacheKey = actionCache.GetCacheKey( ctx, _actionName );
            if (strUtil.HasText( _cacheKey )) {
                _isActionCache = true;
            }
        }
Пример #3
0
        //----------------------------------------------------------------------


        private void initCacheKey(ActionCache actionCache, MvcContext ctx)
        {
            if (actionCache == null)
            {
                return;
            }

            // 只在 GET 下缓存
            if (ctx.HttpMethod.Equals("GET") == false)
            {
                return;
            }

            _cacheKey = actionCache.GetCacheKey(ctx, _actionName);
            if (strUtil.HasText(_cacheKey))
            {
                _isActionCache = true;
            }
        }
Пример #4
0
        private static ActionCacheChecker initPrivate(MvcContext ctx, ControllerBase controller, Boolean isLayout)
        {
            ActionCacheChecker x = new ActionCacheChecker();

            if (MvcConfig.Instance.IsActionCache == false)
            {
                return(x);
            }

            // 模拟的context环境下,不缓存
            if (ctx.web.GetType() != typeof(WebContext))
            {
                return(x);
            }

            x._actionName = isLayout ? "Layout" : ctx.route.action;

            ActionCache actionCache = ControllerMeta.GetActionCacheAttr(controller.GetType(), x._actionName);

            x.initCacheKey(actionCache, ctx);


            return(x);
        }