当前位置: 首页>>代码示例>>C#>>正文


C# MvcContext类代码示例

本文整理汇总了C#中MvcContext的典型用法代码示例。如果您正苦于以下问题:C# MvcContext类的具体用法?C# MvcContext怎么用?C# MvcContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MvcContext类属于命名空间,在下文中一共展示了MvcContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateCategory

        public static ForumCategory ValidateCategory( ForumCategory category, MvcContext ctx )
        {
            if (category == null) category = new ForumCategory();

            String name = ctx.Post( "Name" );
            if (strUtil.IsNullOrEmpty( name ))
                ctx.errors.Add( lang.get( "exName" ) );

            String nameColor = ctx.Post( "NameColor" );
            if (strUtil.HasText( nameColor )) {
                String errorInfo = alang( ctx, "exColorFormat" );
                if (nameColor.Length != 7) ctx.errors.Add( errorInfo );
                if (nameColor.StartsWith( "#" ) == false) ctx.errors.Add( errorInfo );
            }

            int boardId = ctx.PostInt( "BoardId" );

            category.Name = name;
            category.NameColor = nameColor;
            category.BoardId = boardId;
            category.OwnerId = ctx.owner.Id;
            category.OwnerType = ctx.owner.obj.GetType().FullName;
            category.Creator = (User)ctx.viewer.obj;

            return category;
        }
开发者ID:robin88,项目名称:wojilu,代码行数:26,代码来源:ForumValidator.cs

示例2: bindListItem

        public static void bindListItem( IBlock block, ContentPost post, MvcContext ctx )
        {
            block.Set( "post.SectionName", post.PageSection.Title );
            block.Set( "post.SectionUrl", ctx.to( new SectionController().Show, post.PageSection.Id ) );

            String typeIcon = BinderUtils.getTypeIcon( post );
            block.Set( "post.ImgIcon", typeIcon );

            String att = post.Attachments > 0 ? "<img src=\"" + strUtil.Join( sys.Path.Img, "attachment.gif" ) + "\"/>" : "";
            block.Set( "post.AttachmentIcon", att );

            block.Set( "post.TitleCss", post.Style );

            block.Set( "post.Title", strUtil.SubString( post.GetTitle(), 50 ) );
            block.Set( "post.Created", post.Created );
            block.Set( "post.Hits", post.Hits );
            block.Set( "post.Url", alink.ToAppData( post ) );

            if (post.Creator != null) {
                block.Set( "post.Submitter", string.Format( "<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember( post.Creator ), post.Creator.Name ) );
            }
            else {
                block.Set( "post.Submitter", "" );
            }
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:25,代码来源:BinderUtils.cs

示例3: GetCacheKey

        public override string GetCacheKey( MvcContext ctx, string actionName ) {

            if (actionName != "Layout") return null;
            if (ctx.owner.obj.GetType() != typeof( Site )) return null;

            return getCacheKey( ctx );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:7,代码来源:ContentLayoutCache.cs

示例4: clearUrl

        public static String clearUrl( IAppData data, MvcContext ctx )
        {
            String ownerPath = Link.GetMemberPathPrefix( data.OwnerType, data.OwnerUrl );
            ownerPath = ownerPath.TrimStart( '/' );

            return clearUrl( alink.ToAppData( data ), ownerPath, ctx );
        }
开发者ID:robin88,项目名称:wojilu,代码行数:7,代码来源:UrlConverter.cs

示例5: getMenuFullPath

        /// <summary>
        /// 不包括http、域名、application path和网址后缀(仅仅是path)
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="menu"></param>
        /// <returns></returns>
        public static String getMenuFullPath( MvcContext ctx, IMenu menu )
        {
            String url = menu.RawUrl;
            String ownerPathAndUrl = getMemberPathUrlByMenu( menu );

            // 带http的完整网址
            Boolean isFullUrl = PathHelper.IsFullUrl( url );
            if (isFullUrl) return url;

            // 包括完整的ownerPath
            if (url.StartsWith( "/" )) {
                return url + MvcConfig.Instance.UrlExt;
            }

            String result = url;
            if (url.StartsWith( ctx.url.AppPath )) {
                result = strUtil.TrimStart( url, ctx.url.AppPath );
            }

            if (result.StartsWith( ownerPathAndUrl )) {
                result = strUtil.TrimStart( result, ownerPathAndUrl );
            }
            if (result.StartsWith( "/" + ownerPathAndUrl ) && strUtil.HasText( ownerPathAndUrl )) {
                result = strUtil.TrimStart( result, "/" + ownerPathAndUrl );
            }

            String location = strUtil.Join( ctx.url.AppPath, ownerPathAndUrl );
            result = strUtil.Join( location, result );
            return result;
        }
开发者ID:robin88,项目名称:wojilu,代码行数:36,代码来源:UrlConverter.cs

示例6: CreateAppAndMenu

        public virtual void CreateAppAndMenu( Group group, MvcContext ctx ) {
            
            // 添加程序
            IMemberApp forumApp = appService.Add( (User)ctx.viewer.obj, @group, lang.get( "groupBoard" ), 1, AccessStatus.Public );

            // 论坛
            ForumApp app = forumService.GetById( forumApp.AppOid );
            ForumPermission.AddOwnerAdminPermission( app );

            // 添加一个论坛板块
            ForumBoard board = new ForumBoard();
            board.Name = lang.get( "groupBoard" );
            board.ParentId = 0;
            board.AppId = forumApp.AppOid;

            board.Creator = (User)ctx.viewer.obj;
            board.CreatorUrl = ctx.viewer.obj.Url;

            board.OwnerId = group.Id;
            board.OwnerUrl = group.Url;
            board.OwnerType = typeof( Group ).FullName;
            board.Ip = ctx.Ip;

            board.Security = app.Security;

            db.insert( board );

            // 添加menuUrl
            String forumUrl = UrlConverter.clearUrl( board, ctx );
            menuService.AddMenuByApp( forumApp, forumApp.Name, "default", forumUrl );

        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:32,代码来源:GroupUtil.cs

示例7: GetCacheKey

        public string GetCacheKey( MvcContext ctx, string actionName )
        {
            IMember owner = ctx.owner.obj;
            int appId = ctx.app.Id;

            return owner.GetType().FullName + "_" + owner.Url + "_" + typeof( wojilu.Web.Controller.Content.Section.LayoutController ).FullName + ".Layout" + "_app" + appId;
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:7,代码来源:ContentLayoutFilter.cs

示例8: bindUserInfo

        private static void bindUserInfo( IBlock block, MvcContext ctx, Microblog blog, Boolean showUserFace )
        {
            IBlock ufBlock = block.GetBlock( "userFace" );
            if (showUserFace) {

                ufBlock.Set( "blog.UserName", blog.User.Name );
                ufBlock.Set( "blog.UserFace", blog.User.PicSmall );

                if (ctx.GetItemString( "_showType" ) == "microblog") {
                    ufBlock.Set( "blog.UserLink", alink.ToUserMicroblog( blog.User ) );
                    ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) );
                }
                else {
                    ufBlock.Set( "blog.UserLink", Link.ToMember( blog.User ) );
                    ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) );
                }

                String deleteCmd = getDeleteCmd( ctx, blog );
                ufBlock.Set( "blog.DeleteCmd", deleteCmd );

                ufBlock.Next();

                if (ctx.GetItemString( "_showType" ) == "microblog") {
                    block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) );
                }
                else {
                    block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) );
                }

            }
            else {
                block.Set( "userNameInfo", "" );
            }
        }
开发者ID:KDF5000,项目名称:wojilu,代码行数:34,代码来源:MicroblogController.cs

示例9: getFriendlyUrls

        protected virtual List<String> getFriendlyUrls( MvcContext ctx, IMember owner, String rawUrl )
        {
            List<String> furls = new List<String>();

            List<IMenu> list = InitHelperFactory.GetHelper( owner.GetType(), ctx ).GetMenus( owner );

            foreach (IMenu menu in list) {

                if (strUtil.EqualsIgnoreCase( rawUrl, getFullUrl( menu.RawUrl ) )) {

                    String urlKey = "/" + menu.Url + MvcConfig.Instance.UrlExt;
                    furls.Add( urlKey );

                    if (menu.Url == "default") { // 在静态页面的时候,有多种结果:/和/Default.aspx
                        furls.Add( "/" );
                        furls.Add( "/default" + MvcConfig.Instance.UrlExt );
                        furls.Add( "/Default" + MvcConfig.Instance.UrlExt );
                    }

                }

            }

            return furls;
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:25,代码来源:CorePageCache.cs

示例10: GetBoard

 public static String GetBoard( List<ForumBoard> boards, MvcContext ctx ) {
     StringBuilder sb = getBuilder( boards, ctx );
     int length = separator.Length + 1;
     sb.Remove( sb.Length - length, separator.Length + 1 );
     appendEnd( sb );
     return sb.ToString();
 }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:7,代码来源:ForumLocationUtil.cs

示例11: CreatePost

        public virtual Result CreatePost( Result uploadResult, String photoName, int albumId, MvcContext ctx )
        {
            String path = uploadResult.Info.ToString();
            if (strUtil.IsNullOrEmpty( photoName )) {
                photoName = Path.GetFileNameWithoutExtension( path );
            }
            photoName = strUtil.CutString( photoName, 30 );
            PhotoAlbum album = getAlbum( albumId, ctx.viewer.obj as User );

            PhotoPost photo = new PhotoPost();
            photo.AppId = album.AppId;
            photo.Creator = (User)ctx.viewer.obj;
            photo.CreatorUrl = ctx.viewer.obj.Url;
            photo.OwnerId = ctx.owner.Id;
            photo.OwnerUrl = ctx.owner.obj.Url;
            photo.OwnerType = ctx.owner.obj.GetType().FullName;
            photo.Title = photoName;
            photo.DataUrl = path;
            photo.PhotoAlbum = album;
            photo.Ip = ctx.Ip;

            Result result = db.insert( photo );
            if (result.IsValid) {
                this.updatePostCount( ctx.app.obj as PhotoApp );
            }
            return result;
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:27,代码来源:PhotoPostService.cs

示例12: showErrorInfo

 private static String showErrorInfo( String result, MvcContext ctx )
 {
     if (ctx.errors.HasErrors && ctx.errors.AutoShow) {
         result = Regex.Replace( result, "(<form.+?>)", "$1 " + ctx.errors.ErrorsHtml, RegexOptions.IgnoreCase );
     }
     return result;
 }
开发者ID:Boshin,项目名称:wojilu,代码行数:7,代码来源:PostValueProcessor.cs

示例13: BeforeAction

        public override bool BeforeAction( MvcContext ctx )
        {
            ContentPost post = postService.GetById( ctx.route.id, ctx.owner.Id );
            _contentPost = post;

            return base.BeforeAction( ctx );
        }
开发者ID:Boshin,项目名称:wojilu,代码行数:7,代码来源:PostDeleteObserver.cs

示例14: Init

        public void Init( MvcContext ctx )
        {
            if (ctx.utils.isEnd()) return;

            CurrentRequest.setItem( "_user_factory", new UserFactory() );

            User user = this.getViewer( ctx );

            if (user.Id == UserFactory.Guest.Id && ctx.web.UserIsLogin) {
                signOut( ctx );
                return;
            }
            else if (user.Status == MemberStatus.Deleted || user.Status == MemberStatus.Approving) {
                signOut( ctx );
                return;
            }

            if (ctx.web.UserIsLogin) loginService.UpdateLastLogin( user, ctx.Ip );

            ViewerContext context = new ViewerContext();
            context.Id = user.Id;
            context.obj = user;
            context.IsLogin = ctx.web.UserIsLogin;
            ctx.utils.setViewerContext( context );
        }
开发者ID:jilumvc,项目名称:Sajoo,代码行数:25,代码来源:ViewerInit.cs

示例15: GetCacheKey

        public override string GetCacheKey( MvcContext ctx, string actionName ) {

            if (!(ctx.owner.obj is Site)) return null;
            if (ctx.route.isAdmin || ctx.route.isUserDataAdmin) return null;

            return getKey();
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:7,代码来源:SiteLayoutCache.cs


注:本文中的MvcContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。