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

有点意思

时间:2015-02-25 06:58:51      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

Role类

技术分享
 public sealed class Role
    {
        private string value = null;

        private Role(string value)
        {
            this.value = value;
        }

        public string Value
        {
            get { return this.value; }
        }

        public static Role GetRole(string roleCode)
        {
            switch (roleCode)
            {
                case "1A":
                    return Applicant;
                case "1B":
                    return Coworker;
                case "2A":
                    return Superior;
                case "3A":
                    return Secretariat;
                case "4A":
                    return Committee;
                case "4B":
                    return Observer;
                case "5A":
                    return Chairperson;
                case "9A":
                    return SystemAdministrator;
                default:
                    throw new InvalidOperationException();
            }
        }

        public override string ToString()
        {
            switch (this.value)
            {
                case "1A":
                    return "申請者";
                case "1B":
                    return "同僚";
                case "2A":
                    return "上長";
                case "3A":
                    return "事務局";
                case "4A":
                    return "委員";
                case "4B":
                    return "オブザーバー";
                case "5A":
                    return "委員長";
                case "9A":
                    return "システム運用管理者";
                default:
                    throw new NotImplementedException();
            }
        }

        public static Role Applicant = new Role("1A");
        public static Role Coworker = new Role("1B");
        public static Role Superior = new Role("2A");
        public static Role Secretariat = new Role("3A");
        public static Role Committee = new Role("4A");
        public static Role Observer = new Role("4B");
        public static Role Chairperson = new Role("5A");
        public static Role SystemAdministrator = new Role("9A");
    }
View Code

调用索引器

技术分享
    /// <summary>
    /// 委員会ボタン押下
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommittee_Click(object sender, EventArgs e)
    {
        // 委員会メンバーを検索する
        List<string> roleCode = new List<string>();
        roleCode.Add(Role.Committee.Value);
        roleCode.Add(Role.Chairperson.Value);
        search(roleCode);
    }
View Code

 

有点意思

标签:

原文地址:http://www.cnblogs.com/haiy/p/4155198.html

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