通过父类创建子类

发布时间 2023-08-28 23:41:52作者: 牛腩
通过父类创建子类
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZZX.Model.ViewModel
{
    /// <summary>
    /// 用户所申请的工作
    /// </summary>
    public class UserJob:Job
    {
        /// <summary>
        /// 子类构造函数
        /// </summary>
        /// <param name="parent">父类对象</param>
        public UserJob(Job parent)
        {
            var parentProperties = parent.GetType().GetProperties();
            foreach (var parentProperty in parentProperties)
            {
                var thisProperty = this.GetType().GetProperty(parentProperty.Name, parentProperty.PropertyType);
                var value = parentProperty.GetValue(parent);
                if (thisProperty != null && value != null && thisProperty.CanWrite)
                {
                    thisProperty.SetValue(this, value);
                }
            }
        }


        /// <summary>
        /// 申请状态
        /// </summary>
        public int ApplyStatus { set; get; }
        /// <summary>
        /// 申请状态描述
        /// </summary>
        public string ApplyStatusText { set; get; }
        /// <summary>
        /// 申请领薪资的方式
        /// </summary>
       public int ApplySalaryWay { set; get; }
        /// <summary>
        /// 申请领薪资的方式描述
        /// </summary>
        public string ApplySalaryWayText { set; get; }
    }
}