示例#1
0
        //---------------------------------------------------------------------------------------------------------


        private static Dictionary <String, IPageCache> loadIPageCaches()
        {
            Dictionary <String, IPageCache> results = new Dictionary <String, IPageCache>();

            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)
                    {
                        CachePageAttribute cachedInfo = a as CachePageAttribute;
                        if (cachedInfo == null)
                        {
                            continue;
                        }

                        IPageCache obj = (IPageCache)ObjectContext.GetByType(cachedInfo.Type);

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

            return(results);
        }
示例#2
0
        private static ControllerMeta loadControllerSingle(Type controllerType)
        {
            ControllerMeta cm = new ControllerMeta();

            cm.ControllerType = controllerType;

            object[] attrs = rft.GetAttributes(cm.ControllerType);
            cm.AttributeList = new List <Attribute>();
            foreach (Attribute a in attrs)
            {
                cm.AttributeList.Add(a);
            }

            MethodInfo[] mi = rft.GetMethodsAll(cm.ControllerType);
            cm.ActionMaps = loadActionMaps(mi);
            return(cm);
        }
示例#3
0
        //------------------------------ ControllerMeta -----------------------------------------------------------------------------

        private static Dictionary <String, ControllerMeta> loadControllerMeta()
        {
            Dictionary <String, ControllerMeta> metas = new Dictionary <String, ControllerMeta>();

            foreach (KeyValuePair <String, Type> kv in ObjectContext.Instance.TypeList)
            {
                if (kv.Value.IsAbstract)
                {
                    continue;
                }
                if (kv.Value.IsSubclassOf(typeof(ControllerBase)) == false)
                {
                    continue;
                }

                ControllerMeta cm = loadControllerSingle(kv.Value);

                metas.Add(cm.ControllerType.FullName, cm);
            }

            return(metas);
        }
示例#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);
        }
示例#5
0
        private static CacheInfo InitLayout(MvcContext ctx, ControllerBase controller, Boolean isLayout)
        {
            CacheInfo ci = new CacheInfo();

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

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

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

            IActionCache actionCache = ControllerMeta.GetActionCache(controller.GetType(), ci._actionName);

            ci.initCacheKey(actionCache, ctx);


            return(ci);
        }
示例#6
0
        private static ControllerMeta loadControllerSingle( Type controllerType )
        {
            ControllerMeta cm = new ControllerMeta();
            cm.ControllerType = controllerType;

            object[] attrs = rft.GetAttributes( cm.ControllerType );
            cm.AttributeList = new List<Attribute>();
            foreach (Attribute a in attrs) {
                cm.AttributeList.Add( a );
            }

            MethodInfo[] mi = rft.GetMethodsAll( cm.ControllerType );
            cm.ActionMaps = loadActionMaps( mi );
            return cm;
        }