码迷,mamicode.com
首页 > 其他好文 > 详细

今天写个页面跳转helper,厌烦了不停跳的时候定中文写字母名字,还是管理起来好

时间:2015-05-20 16:19:51      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Web;
using JGDJWeb.Helper;
 
/*
 * Created by Calos 2015年5月20日 15:28:59
 **/
namespace System {
 
    /// <summary>
    /// 0519本次的所有pageNames
    /// </summary>
    public enum PageNames {
        单篇 = 0,
        多级列表页 = 1,
        党员驿站 = 2,
        公示公告 = 3,
        列表页 = 4,
        搜索页 = 5,
        图片列表页 = 6,
        详细页 = 7
 
    }
    /// <summary>
    /// 设计静态存储类
    /// </summary>
    public class PageNamesCollection {
        /// <summary>
        /// do not only change the text or order in the list below,it correspond to the enum above
        /// </summary>
        private static readonly IList<string> PageNameShorts = new List<string>()
        {
            "danpian",
            "djlby",
            "dyyzh",
            "gsgg",
            "lby",
            "sousuoye",
            "tplby",
            "xxy"
        };
        private const String Prefix = "Page";
        private const String Suffix = ".aspx";
        public static String GetPageName(PageNames pageName) {
            return Prefix + PageNameShorts[int.Parse(pageName.ToString())] + Suffix;
        }
    }
    public static class Extensions {
        /// <summary>
        /// 添加扩展方法
        /// </summary>
        /// <param name="pageName"></param>
        /// <returns></returns>
        public static String ToPageTitleCn(this PageNames pageName) {
            return pageName.GetType().GetEnumName(int.Parse(pageName.ToString()));
        }
 
        public static String ToPageName(this PageNames pageName) {
            return PageNamesCollection.GetPageName(pageName);
        }
    }
}

今天写个页面跳转helper,厌烦了不停跳的时候定中文写字母名字,还是管理起来好

标签:

原文地址:http://www.cnblogs.com/hualiu0/p/4517395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!