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

LongClass.SomeModel

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

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

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public SomeModel(SomeModel someModel)
        {
            this.SomeCd = someModel.SomeCd;
            this.Order = someModel.Order;
            this.Nmj = someModel.Nmj;
            this.Nmk = someModel.Nmk;
            this.Nms = someModel.Nms;
            this.SomeAreaCd = someModel.SomeAreaCd;
            this.SomeType = someModel.SomeType;
            this.Mode = someModel.Mode;
            this.Catego = someModel.Catego;
            this.WarehouseCd = someModel.WarehouseCd;
            this.Postno = someModel.Postno;
            this.Addre1 = someModel.Addre1;
            this.Addre2 = someModel.Addre2;
            this.Addre3 = someModel.Addre3;
            this.Telno = someModel.Telno;
            this.Faxno = someModel.Faxno;
            this.Url = someModel.Url;
            this.EMail = someModel.EMail;
            this.FloorNum = someModel.FloorNum;
            this.PosNum = someModel.PosNum;
            this.EmpNum = someModel.EmpNum;
            this.Rest = someModel.Rest;
            this.Rsv1 = someModel.Rsv1;
            this.Rsv2 = someModel.Rsv2;
            this.Rsv3 = someModel.Rsv3;
            this.ActiveFlg = someModel.ActiveFlg;
            this.UpdateFlg = someModel.UpdateFlg;
            this.UpdateYmd = someModel.UpdateYmd;
            this.RegistYmd = someModel.RegistYmd;
            this.ModifyYmd = someModel.ModifyYmd;
            this.RegistSomeCd = someModel.RegistSomeCd;
            this.RegistEmpCd = someModel.RegistEmpCd;
        }

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

            /// <summary>
            /// 表示順
            /// </summary>
            public const string Order = "Order";

            /// <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>
            public const string SomeType = "SomeType";

            /// <summary>
            /// 何か形態
            /// </summary>
            public const string Mode = "Mode";

            /// <summary>
            /// 契約形態
            /// </summary>
            public const string Catego = "Catego";

            /// <summary>
            /// 倉庫コード
            /// </summary>
            public const string WarehouseCd = "WarehouseCd";

            /// <summary>
            /// 郵便番号
            /// </summary>
            public const string Postno = "Postno";

            /// <summary>
            /// 住所1
            /// </summary>
            public const string Addre1 = "Addre1";

            /// <summary>
            /// 住所2
            /// </summary>
            public const string Addre2 = "Addre2";

            /// <summary>
            /// 住所3
            /// </summary>
            public const string Addre3 = "Addre3";

            /// <summary>
            /// 電話番号
            /// </summary>
            public const string Telno = "Telno";

            /// <summary>
            /// FAX番号
            /// </summary>
            public const string Faxno = "Faxno";

            /// <summary>
            /// URL
            /// </summary>
            public const string Url = "Url";

            /// <summary>
            /// E-Mailアドレス
            /// </summary>
            public const string EMail = "EMail";

            /// <summary>
            /// 床数
            /// </summary>
            public const string FloorNum = "FloorNum";

            /// <summary>
            /// POS台数
            /// </summary>
            public const string PosNum = "PosNum";

            /// <summary>
            /// 参加者数
            /// </summary>
            public const string EmpNum = "EmpNum";

            /// <summary>
            /// 定休日
            /// </summary>
            public const string Rest = "Rest";

            /// <summary>
            /// 区分1
            /// </summary>
            public const string Rsv1 = "Rsv1";

            /// <summary>
            /// 区分2
            /// </summary>
            public const string Rsv2 = "Rsv2";

            /// <summary>
            /// 区分3
            /// </summary>
            public const string Rsv3 = "Rsv3";

            /// <summary>
            /// 稼動フラグ
            /// </summary>
            public const string ActiveFlg = "ActiveFlg";

            /// <summary>
            /// 更新フラグ
            /// </summary>
            public const string UpdateFlg = "UpdateFlg";

            /// <summary>
            /// 更新実行日
            /// </summary>
            public const string UpdateYmd = "UpdateYmd";

            /// <summary>
            /// 登録日
            /// </summary>
            public const string RegistYmd = "RegistYmd";

            /// <summary>
            /// 修正日
            /// </summary>
            public const string ModifyYmd = "ModifyYmd";

            /// <summary>
            /// 登録何かコード
            /// </summary>
            public const string RegistSomeCd = "RegistSomeCd";

            /// <summary>
            /// 登録参加者コード
            /// </summary>
            public const string RegistEmpCd = "RegistEmpCd";
        }

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


        /// <summary>
        /// 何かコード
        /// </summary>
        private string _someCd = string.Empty;

        /// <summary>
        /// 表示順
        /// </summary>
        private int _order = 0;

        /// <summary>
        /// 名称漢字
        /// </summary>
        private string _nmj = string.Empty;

        /// <summary>
        /// 名称カナ
        /// </summary>
        private string _nmk = string.Empty;

        /// <summary>
        /// 略称
        /// </summary>
        private string _nms = string.Empty;

        /// <summary>
        /// 何かグループコード
        /// </summary>
        private string _someAreaCd = string.Empty;

        /// <summary>
        /// 何か区分
        /// </summary>
        private int _someType = 0;

        /// <summary>
        /// 何か形態
        /// </summary>
        private int _mode = 0;

        /// <summary>
        /// 契約形態
        /// </summary>
        private int _catego = 0;

        /// <summary>
        /// 倉庫コード
        /// </summary>
        private string _warehouseCd = string.Empty;

        /// <summary>
        /// 郵便番号
        /// </summary>
        private string _postno = string.Empty;

        /// <summary>
        /// 住所1
        /// </summary>
        private string _addre1 = string.Empty;

        /// <summary>
        /// 住所2
        /// </summary>
        private string _addre2 = string.Empty;

        /// <summary>
        /// 住所3
        /// </summary>
        private string _addre3 = string.Empty;

        /// <summary>
        /// 電話番号
        /// </summary>
        private string _telno = string.Empty;

        /// <summary>
        /// FAX番号
        /// </summary>
        private string _faxno = string.Empty;

        /// <summary>
        /// URL
        /// </summary>
        private string _url = string.Empty;

        /// <summary>
        /// E-Mailアドレス
        /// </summary>
        private string _eMail = string.Empty;

        /// <summary>
        /// 床数
        /// </summary>
        private decimal _floorNum = decimal.Zero;

        /// <summary>
        /// POS台数
        /// </summary>
        private decimal _posNum = 0;

        /// <summary>
        /// 参加者数
        /// </summary>
        private decimal _empNum = 0;

        /// <summary>
        /// 定休日
        /// </summary>
        private DateTime _rest = new DateTime();

        /// <summary>
        /// 区分1
        /// </summary>
        private string _rsv1 = string.Empty;

        /// <summary>
        /// 区分2
        /// </summary>
        private string _rsv2 = string.Empty;

        /// <summary>
        /// 区分3
        /// </summary>
        private string _rsv3 = string.Empty;

        /// <summary>
        /// 稼動フラグ
        /// </summary>
        private bool _activeFlg = false;

        /// <summary>
        /// 更新フラグ
        /// </summary>
        private bool _updateFlg = false;

        /// <summary>
        /// 更新実行日
        /// </summary>
        private DateTime _updateYmd = new DateTime();

        /// <summary>
        /// 登録日
        /// </summary>
        private DateTime _registYmd = new DateTime();

        /// <summary>
        /// 修正日
        /// </summary>
        private DateTime _modifyYmd = new DateTime();

        /// <summary>
        /// 登録何かコード
        /// </summary>
        private string _registSomeCd = string.Empty;

        /// <summary>
        /// 登録参加者コード
        /// </summary>
        private string _registEmpCd = string.Empty;



        /// <summary>
        /// 何かコード
        /// </summary>
        public string SomeCd
        {
            get
            {
                return this._someCd;
            }
            set
            {
                if (this._someCd == value)
                {
                    return;
                }
                this._someCd = value;
                this.OnPropertyChanged(PropertyName.SomeCd);
            }
        }

        /// <summary>
        /// 表示順
        /// </summary>
        public int Order
        {
            get
            {
                return this._order;
            }
            set
            {
                if (this._order == value)
                {
                    return;
                }
                this._order = value;
                this.OnPropertyChanged(PropertyName.Order);
            }
        }

        /// <summary>
        /// 名称漢字
        /// </summary>
        public string Nmj
        {
            get
            {
                return this._nmj;
            }
            set
            {
                if (this._nmj == value)
                {
                    return;
                }
                this._nmj = value;
                this.OnPropertyChanged(PropertyName.Nmj);
            }
        }

        /// <summary>
        /// 名称カナ
        /// </summary>
        public string Nmk
        {
            get
            {
                return this._nmk;
            }
            set
            {
                if (this._nmk == value)
                {
                    return;
                }
                this._nmk = value;
                this.OnPropertyChanged(PropertyName.Nmk);
            }
        }

        /// <summary>
        /// 略称
        /// </summary>
        public string Nms
        {
            get
            {
                return this._nms;
            }
            set
            {
                if (this._nms == value)
                {
                    return;
                }
                this._nms = value;
                this.OnPropertyChanged(PropertyName.Nms);
            }
        }

        /// <summary>
        /// 何かグループコード
        /// </summary>
        public string SomeAreaCd
        {
            get
            {
                return this._someAreaCd;
            }
            set
            {
                if (this._someAreaCd == value)
                {
                    return;
                }
                this._someAreaCd = value;
                this.OnPropertyChanged(PropertyName.SomeAreaCd);
            }
        }

        /// <summary>
        /// 何か区分
        /// </summary>
        public int SomeType
        {
            get
            {
                return this._someType;
            }
            set
            {
                if (this._someType == value)
                {
                    return;
                }
                this._someType = value;
                this.OnPropertyChanged(PropertyName.SomeType);
            }
        }

        /// <summary>
        /// 何か形態
        /// </summary>
        public int Mode
        {
            get
            {
                return this._mode;
            }
            set
            {
                if (this._mode == value)
                {
                    return;
                }
                this._mode = value;
                this.OnPropertyChanged(PropertyName.Mode);
            }
        }

        /// <summary>
        /// 契約形態
        /// </summary>
        public int Catego
        {
            get
            {
                return this._catego;
            }
            set
            {
                if (this._catego == value)
                {
                    return;
                }
                this._catego = value;
                this.OnPropertyChanged(PropertyName.Catego);
            }
        }

        /// <summary>
        /// 倉庫コード
        /// </summary>
        public string WarehouseCd
        {
            get
            {
                return this._warehouseCd;
            }
            set
            {
                if (this._warehouseCd == value)
                {
                    return;
                }
                this._warehouseCd = value;
                this.OnPropertyChanged(PropertyName.WarehouseCd);
            }
        }

        /// <summary>
        /// 郵便番号
        /// </summary>
        public string Postno
        {
            get
            {
                return this._postno;
            }
            set
            {
                if (this._postno == value)
                {
                    return;
                }
                this._postno = value;
                this.OnPropertyChanged(PropertyName.Postno);
            }
        }

        /// <summary>
        /// 住所1
        /// </summary>
        public string Addre1
        {
            get
            {
                return this._addre1;
            }
            set
            {
                if (this._addre1 == value)
                {
                    return;
                }
                this._addre1 = value;
                this.OnPropertyChanged(PropertyName.Addre1);
            }
        }

        /// <summary>
        /// 住所2
        /// </summary>
        public string Addre2
        {
            get
            {
                return this._addre2;
            }
            set
            {
                if (this._addre2 == value)
                {
                    return;
                }
                this._addre2 = value;
                this.OnPropertyChanged(PropertyName.Addre2);
            }
        }

        /// <summary>
        /// 住所3
        /// </summary>
        public string Addre3
        {
            get
            {
                return this._addre3;
            }
            set
            {
                if (this._addre3 == value)
                {
                    return;
                }
                this._addre3 = value;
                this.OnPropertyChanged(PropertyName.Addre3);
            }
        }

        /// <summary>
        /// 電話番号
        /// </summary>
        public string Telno
        {
            get
            {
                return this._telno;
            }
            set
            {
                if (this._telno == value)
                {
                    return;
                }
                this._telno = value;
                this.OnPropertyChanged(PropertyName.Telno);
            }
        }

        /// <summary>
        /// FAX番号
        /// </summary>
        public string Faxno
        {
            get
            {
                return this._faxno;
            }
            set
            {
                if (this._faxno == value)
                {
                    return;
                }
                this._faxno = value;
                this.OnPropertyChanged(PropertyName.Faxno);
            }
        }

        /// <summary>
        /// URL
        /// </summary>
        public string Url
        {
            get
            {
                return this._url;
            }
            set
            {
                if (this._url == value)
                {
                    return;
                }
                this._url = value;
                this.OnPropertyChanged(PropertyName.Url);
            }
        }

        /// <summary>
        /// E-Mailアドレス
        /// </summary>
        public string EMail
        {
            get
            {
                return this._eMail;
            }
            set
            {
                if (this._eMail == value)
                {
                    return;
                }
                this._eMail = value;
                this.OnPropertyChanged(PropertyName.EMail);
            }
        }

        /// <summary>
        /// 床数
        /// </summary>
        public decimal FloorNum
        {
            get
            {
                return this._floorNum;
            }
            set
            {
                if (this._floorNum == value)
                {
                    return;
                }
                this._floorNum = value;
                this.OnPropertyChanged(PropertyName.FloorNum);
            }
        }

        /// <summary>
        /// POS台数
        /// </summary>
        public decimal PosNum
        {
            get
            {
                return this._posNum;
            }
            set
            {
                if (this._posNum == value)
                {
                    return;
                }
                this._posNum = value;
                this.OnPropertyChanged(PropertyName.PosNum);
            }
        }

        /// <summary>
        /// 参加者数
        /// </summary>
        public decimal EmpNum
        {
            get
            {
                return this._empNum;
            }
            set
            {
                if (this._empNum == value)
                {
                    return;
                }
                this._empNum = value;
                this.OnPropertyChanged(PropertyName.EmpNum);
            }
        }

        /// <summary>
        /// 定休日
        /// </summary>
        public DateTime Rest
        {
            get
            {
                return this._rest;
            }
            set
            {
                if (this._rest == value)
                {
                    return;
                }
                this._rest = value;
                this.OnPropertyChanged(PropertyName.Rest);
            }
        }

        /// <summary>
        /// 区分1
        /// </summary>
        public string Rsv1
        {
            get
            {
                return this._rsv1;
            }
            set
            {
                if (this._rsv1 == value)
                {
                    return;
                }
                this._rsv1 = value;
                this.OnPropertyChanged(PropertyName.Rsv1);
            }
        }

        /// <summary>
        /// 区分2
        /// </summary>
        public string Rsv2
        {
            get
            {
                return this._rsv2;
            }
            set
            {
                if (this._rsv2 == value)
                {
                    return;
                }
                this._rsv2 = value;
                this.OnPropertyChanged(PropertyName.Rsv2);
            }
        }

        /// <summary>
        /// 区分3
        /// </summary>
        public string Rsv3
        {
            get
            {
                return this._rsv3;
            }
            set
            {
                if (this._rsv3 == value)
                {
                    return;
                }
                this._rsv3 = value;
                this.OnPropertyChanged(PropertyName.Rsv3);
            }
        }

        /// <summary>
        /// 稼動フラグ
        /// </summary>
        public bool ActiveFlg
        {
            get
            {
                return this._activeFlg;
            }
            set
            {
                if (this._activeFlg == value)
                {
                    return;
                }
                this._activeFlg = value;
                this.OnPropertyChanged(PropertyName.ActiveFlg);
            }
        }

        /// <summary>
        /// 更新フラグ
        /// </summary>
        public bool UpdateFlg
        {
            get
            {
                return this._updateFlg;
            }
            set
            {
                if (this._updateFlg == value)
                {
                    return;
                }
                this._updateFlg = value;
                this.OnPropertyChanged(PropertyName.UpdateFlg);
            }
        }

        /// <summary>
        /// 更新実行日
        /// </summary>
        public DateTime UpdateYmd
        {
            get
            {
                return this._updateYmd;
            }
            set
            {
                if (this._updateYmd == value)
                {
                    return;
                }
                this._updateYmd = value;
                this.OnPropertyChanged(PropertyName.UpdateYmd);
            }
        }

        /// <summary>
        /// 登録日
        /// </summary>
        public DateTime RegistYmd
        {
            get
            {
                return this._registYmd;
            }
            set
            {
                if (this._registYmd == value)
                {
                    return;
                }
                this._registYmd = value;
                this.OnPropertyChanged(PropertyName.RegistYmd);
            }
        }

        /// <summary>
        /// 修正日
        /// </summary>
        public DateTime ModifyYmd
        {
            get
            {
                return this._modifyYmd;
            }
            set
            {
                if (this._modifyYmd == value)
                {
                    return;
                }
                this._modifyYmd = value;
                this.OnPropertyChanged(PropertyName.ModifyYmd);
            }
        }

        /// <summary>
        /// 登録何かコード
        /// </summary>
        public string RegistSomeCd
        {
            get
            {
                return this._registSomeCd;
            }
            set
            {
                if (this._registSomeCd == value)
                {
                    return;
                }
                this._registSomeCd = value;
                this.OnPropertyChanged(PropertyName.RegistSomeCd);
            }
        }

        /// <summary>
        /// 登録参加者コード
        /// </summary>
        public string RegistEmpCd
        {
            get
            {
                return this._registEmpCd;
            }
            set
            {
                if (this._registEmpCd == value)
                {
                    return;
                }
                this._registEmpCd = value;
                this.OnPropertyChanged(PropertyName.RegistEmpCd);
            }
        }

        /// <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