Example #1
0
        /// <summary>
        /// Constructor for Kingdom_Serialised taking seperate values.
        /// For creating Kingdom_Serialised from CSV file.
        /// </summary>
        /// <param name="nat">Kingdom's Nationality object</param>
        public Kingdom_Serialised(String id, String nam, byte r, string nat, String tiHo = null, string own = null)
            : base(id, nam, r, own: own, tiHo: tiHo)
        {
            // VALIDATION

            // NAT
            // trim and ensure 1st is uppercase
            nat = Utility_Methods.FirstCharToUpper(nat.Trim());

            if (!Utility_Methods.ValidateNationalityID(nat))
            {
                throw new InvalidDataException("Kingdom_Serialised nationality ID must be 1-3 characters long, and consist entirely of letters");
            }

            this.nationality = nat;
        }
Example #2
0
        /// <summary>
        /// Constructor for Position_Serialised taking seperate values.
        /// For creating Position_Serialised from CSV file.
        /// </summary>
        /// <param name="id">byte holding Position ID</param>
        /// <param name="ti">title name in various languages</param>
        /// <param name="stat">byte holding stature for this position</param>
        /// <param name="holder">string ID of the office holder</param>
        /// <param name="nat">string holding ID of Nationality associated with the position</param>
        public Position_Serialised(byte id, TitleName[] ti, byte stat, string holder, string nat)
        {
            // VALIDATION

            // STAT
            if (stat < 1)
            {
                stat = 1;
            }
            else if (stat > 3)
            {
                stat = 3;
            }

            // HOLDER
            if (!String.IsNullOrWhiteSpace(holder))
            {
                // trim and ensure 1st is uppercase
                holder = Utility_Methods.FirstCharToUpper(holder.Trim());

                if (!Utility_Methods.ValidateCharacterID(holder))
                {
                    throw new InvalidDataException("Position_Serialised officeHolder id must have the format 'Char_' followed by some numbers");
                }
            }

            // NAT
            // trim and ensure 1st is uppercase
            nat = Utility_Methods.FirstCharToUpper(nat.Trim());

            if (!Utility_Methods.ValidateNationalityID(nat))
            {
                throw new InvalidDataException("Position_Serialised nationality ID must be 1-3 characters long, and consist entirely of letters");
            }

            this.id           = id;
            this.title        = ti;
            this.stature      = stat;
            this.officeHolder = holder;
            this.nationality  = nat;
        }