アプリケーションの定型コードを短くしたい (1)
05/29/2011

ShortRefl1.SomeModel

using System;
using System.Collections;
using System.Collections.Generic;
using CodeCompress;

using System.Reflection;

namespace CodeCompress.ShortRefl1
{
    public class SomeModel : AbstractModel
    {
         /// <summary>
        /// コンストラクタ
        /// </summary>
        public SomeModel()
        {
        }

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public SomeModel(SomeModel someModel)
        {
            CopyByRefl(someModel, this);
        }

        /// <summary>
        /// プロパティ名
        /// </summary>
        public class PropertyName
        {
            /// <summary>
            /// 何かコード
            /// </summary>
            public const string SomeCd = "SomeCd";

            /// <summary>
            /// 名称漢字
            /// </summary>
            public const string Nmj = "Nmj";

            /// <summary>
            /// 名称カナ
            /// </summary>
            public const string Nmk = "Nmk";

            /// <summary>
            /// 略称
            /// </summary>
            public const string Nms = "Nms";

            /// <summary>
            /// 何かグループコード
            /// </summary>
            public const string SomeAreaCd = "SomeAreaCd";

        }

        /// <summary>
        /// メッセージ
        /// </summary>
        private class Message
        {
            /// <summary>
            /// エラー
            /// </summary>
            public class Error
            {
                /// <summary>
                /// 必須入力
                /// </summary>
                public const string Required = "{0}は、必須入力です。";
            }
        }


        /// <summary>
        /// 何かコード
        /// </summary>
        public string SomeCd
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 表示順
        /// </summary>
        public int Order
        {
            get
            {
                return (int)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 名称漢字
        /// </summary>
        public string Nmj
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 名称カナ
        /// </summary>
        public string Nmk
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 略称
        /// </summary>
        public string Nms
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 何かグループコード
        /// </summary>
        public string SomeAreaCd
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 何か区分
        /// </summary>
        public int SomeType
        {
            get
            {
                return (int)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 何か形態
        /// </summary>
        public int Mode
        {
            get
            {
                return (int)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 契約形態
        /// </summary>
        public int Catego
        {
            get
            {
                return (int)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 倉庫コード
        /// </summary>
        public string WarehouseCd
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 郵便番号
        /// </summary>
        public string Postno
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 住所1
        /// </summary>
        public string Addre1
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 住所2
        /// </summary>
        public string Addre2
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 住所3
        /// </summary>
        public string Addre3
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 電話番号
        /// </summary>
        public string Telno
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// FAX番号
        /// </summary>
        public string Faxno
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// URL
        /// </summary>
        public string Url
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// E-Mailアドレス
        /// </summary>
        public string EMail
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 床数
        /// </summary>
        public decimal FloorNum
        {
            get
            {
                return (decimal)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// POS台数
        /// </summary>
        public decimal PosNum
        {
            get
            {
                return (decimal)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 参加者数
        /// </summary>
        public decimal EmpNum
        {
            get
            {
                return (decimal)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 定休日
        /// </summary>
        public DateTime Rest
        {
            get
            {
                return (DateTime)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 区分1
        /// </summary>
        public string Rsv1
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 区分2
        /// </summary>
        public string Rsv2
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 区分3
        /// </summary>
        public string Rsv3
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 稼動フラグ
        /// </summary>
        public bool ActiveFlg
        {
            get
            {
                return (bool)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 更新フラグ
        /// </summary>
        public bool UpdateFlg
        {
            get
            {
                return (bool)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 更新実行日
        /// </summary>
        public DateTime UpdateYmd
        {
            get
            {
                return (DateTime)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 登録日
        /// </summary>
        public DateTime RegistYmd
        {
            get
            {
                return (DateTime)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 修正日
        /// </summary>
        public DateTime ModifyYmd
        {
            get
            {
                return (DateTime)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 登録何かコード
        /// </summary>
        public string RegistSomeCd
        {
            get
            {
                return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this);
            }
            set
            {
                SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this);
            }
        }

        /// <summary>
        /// 登録参加者コード
        /// </summary>
        public string RegistEmpCd
        {
            get { return (string)GetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), this); }
            set { SetPropValue(this.RemoveSetterPrefix(MethodBase.GetCurrentMethod().Name), value, this); }
        }

        /// <summary>
        /// 検証
        /// </summary>
        /// <param name="propertyName">プロパティ名</param>
        /// <returns>エラーメッセージ</returns>
        protected override IEnumerable Validate(string propertyName)
        {
            List<string> message = new List<string>();

            switch (propertyName)
            {
                case PropertyName.SomeCd:
                    // 何かコード
                    if (string.IsNullOrEmpty(this.SomeCd))
                    {
                        message.Add(string.Format(Message.Error.Required, "何かコード"));
                    }
                    break;
                case PropertyName.SomeAreaCd:
                    // 何かグループコード
                    if (string.IsNullOrEmpty(this.SomeAreaCd))
                    {
                        message.Add(string.Format(Message.Error.Required, "何かグループ"));
                    }
                    break;
                case PropertyName.Nmj:
                    // 名称漢字
                    if (string.IsNullOrEmpty(this.Nmj))
                    {
                        message.Add(string.Format(Message.Error.Required, "名称(漢字)"));
                    }
                    break;
                case PropertyName.Nmk:
                    // 名称カナ
                    if (string.IsNullOrEmpty(this.Nmk))
                    {
                        message.Add(string.Format(Message.Error.Required, "名称(カナ)"));
                    }
                    break;
                case PropertyName.Nms:
                    // 略称
                    if (string.IsNullOrEmpty(this.Nms))
                    {
                        message.Add(string.Format(Message.Error.Required, "略称(漢字)"));
                    }
                    break;
            }

            if (message.Count == 0)
            {
                return null;
            }
            else
            {
                return message;
            }
        }

    }
}

Top of Site
Copyright (c) 2011 Takao Tamura