Exemplo n.º 1
1
        public static MvcContext GetOne( IMember objOwner )
        {
            MvcContext ctx = getContextInit();

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();
            ctx.utils.setRoute( route );

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();
            viewer.obj = new User();
            ctx.utils.setViewerContext( viewer );

            // owner
            OwnerContext owner = new OwnerContext();
            owner.Id = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext( owner );

            // app
            IAppContext app = new AppContext();
            app.obj = null;
            ctx.utils.setAppContext( app );

            return ctx;
        }
Exemplo n.º 2
1
        public static MvcContext GetOne( IMember objOwner, Type appType, int appId )
        {
            MvcContext ctx = getContextInit();

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();
            route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项
            ctx.utils.setRoute( route );

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();
            viewer.obj = new User();
            ctx.utils.setViewerContext( viewer );

            // owner
            OwnerContext owner = new OwnerContext();
            owner.Id = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext( owner );

            // app
            IAppContext app = new AppContext();
            app.Id = appId;
            app.obj = ndb.findById( appType, appId );
            app.setAppType( appType ); // 如果要使用alang语言包,必须设置此项
            ctx.utils.setAppContext( app );

            return ctx;
        }
Exemplo n.º 3
0
        public static MvcContext GetOne( IMember objOwner, int appId )
        {
            IWebContext webContext = MockWebContext.New( 1, "http://localhost/", new System.IO.StringWriter() );

            MvcContext ctx = new MvcContext( webContext );

            // route
            Route route = new wojilu.Web.Mvc.Routes.Route();
            route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项
            ctx.utils.setRoute( route );

            // viewer: 某些地方需要判断viewer
            ViewerContext viewer = new ViewerContext();
            viewer.obj = new User();
            ctx.utils.setViewerContext( viewer );

            // owner
            OwnerContext owner = new OwnerContext();
            owner.Id = objOwner.Id;
            owner.obj = objOwner;
            ctx.utils.setOwnerContext( owner );

            // app
            IAppContext app = new AppContext();
            app.Id = appId;
            app.obj = BlogApp.findById( appId );
            app.setAppType( typeof( BlogApp ) ); // 如果要使用alang语言包,必须设置此项
            ctx.utils.setAppContext( app );

            return ctx;
        }
Exemplo n.º 4
0
        //-------------------------------- owner ----------------------------------
        public void InitOwner( MvcContext ctx )
        {
            if (strUtil.IsNullOrEmpty( ctx.route.ownerType )) return;

            IMember owner = getHelper( ctx ).getOwnerByUrl( ctx );

            if (owner.Status == MemberStatus.Deleted || owner.Status == MemberStatus.Approving) {
                throw ctx.ex( HttpStatus.NotFound_404, "owner not found" );
            }

            OwnerContext context = new OwnerContext();
            context.Id = owner.Id;
            context.obj = owner;

            ctx.utils.setOwnerContext( context );

            this.updateRoute_ByOwnerMenus( ctx, owner );
        }
Exemplo n.º 5
0
        private void initOwner( Context.MvcContext ctx )
        {
            IMember owner = Site.Instance;

            OwnerContext context = new OwnerContext();
            context.Id = owner.Id;
            context.obj = owner;
            ctx.utils.setOwnerContext( context );
        }