Ejemplo n.º 1
0
        private String getControllerDir()
        {
            String pathRaw = strUtil.GetTypeFullName(controller.GetType());

            // 去掉根目录
            String result = trimRootNamespace(pathRaw).TrimStart('.');

            // 换成路径分隔符
            result = result.Replace('.', '/');

            String pathRoot = MvcConfig.Instance.ViewDir;

            result = strUtil.Join(pathRoot, result);
            result = strUtil.TrimEnd(result, "Controller");

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据容器配置,将依赖关系注入到已有对象中
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="ctx"></param>
 public static void InjectController(ControllerBase controller, MvcContext ctx)
 {
     if (controller == null)
     {
         return;
     }
     ObjectContext.Inject(controller);
     controller.setContext(ctx);
     setControllerAppInfo(controller.GetType(), controller);
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 根据容器配置,将依赖关系注入到已有对象中
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="ctx"></param>
 public static void InjectController( ControllerBase controller, MvcContext ctx )
 {
     if (controller == null) return;
     ObjectContext.Inject( controller );
     controller.setContext( ctx );
     setControllerAppInfo( controller.GetType(), controller );
 }
Ejemplo n.º 8
0
        private String getControllerDirNoViewsDir()
        {
            Type declaringController = _method != null ? this._method.DeclaringType : _controller.GetType();

            String pathRaw = strUtil.GetTypeFullName(declaringController);

            // 去掉根目录
            String result = trimRootNamespace(pathRaw).TrimStart('.');

            // 换成路径分隔符
            result = result.Replace('.', '/');
            result = strUtil.TrimEnd(result, "Controller");
            return(result);
        }