using System;
using System.Runtime.InteropServices;

namespace DeviceRepair.Models.Attr
{
    /// <summary>
    /// DOM转换通用字段映射特性 20230327
    /// （以前都是手动去匹配，这里加强下）
    /// </summary>
    [Serializable]
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    [ComVisible(true)]
    public sealed class DomFieldMapAttribute
        : Attribute
    {
        #region Fields

        /// <summary>
        /// 映射字段名称
        /// </summary>
        private string _mappedFieldName;
        /// <summary>
        /// 映射字段顺序
        /// </summary>
        private int _mappedFieldSequence;
        #endregion

        #region Ctor
        //构造函数，构造函数的参数在特性中也称为“位置参数”。

        /// <summary>
        /// DOM转换通用字段映射特性
        /// </summary>
        public DomFieldMapAttribute()
            : this("", 0)
        {
        }
        /// <summary>
        /// DOM转换通用字段映射特性
        /// </summary>
        /// <param name="cMappedName">映射的字段名称</param>
        /// <param name="iMappedSequence">映射的字段顺序</param>
        public DomFieldMapAttribute(string cMappedName, int iMappedSequence)
        {
            _mappedFieldName = cMappedName;
            _mappedFieldSequence = iMappedSequence;
        }
        #endregion

        #region Property
        /// <summary>
        /// 映射字段名称
        /// </summary>
        public string MappedFieldName
        {
            get { return _mappedFieldName; }
            set { _mappedFieldName = value; }
        }
        /// <summary>
        /// 映射字段顺序
        /// </summary>
        public int MappedFieldSequence
        {
            get { return _mappedFieldSequence; }
            set { _mappedFieldSequence = value; }
        }
        #endregion
    }
}
