自定义属性

    /// <summary>
    /// 脱敏属性
    /// </summary>
    public class SensitiveAttribute:Attribute
    {
        #region Fields
        public SensitiveType SensitiveType { get; set; }

        /// <summary>
        /// 开始位置
        /// </summary>
        public int Start { get; set; }

        /// <summary>
        /// 长度
        /// </summary>
        public int Len { get; set; }

        /// <summary>
        /// 敏感字符替换
        /// </summary>
        public string SensitiveReChar { get; set; }

        #endregion

        #region Constructors and Destructors

        public SensitiveAttribute()
        {
            this.Start = 1;
            this.Len = 2;
            this.SensitiveReChar = "*";
        }

        public SensitiveAttribute(SensitiveType type = SensitiveType.IdNumber,int start = 1,int len = 5,string sensitiveReChar = "*")
        {
            this.SensitiveType = type;
            this.Start = start;
            this.Len = len;
            this.SensitiveReChar = sensitiveReChar;
        }
        #endregion

        #region Public Methods and Operators

        #endregion
    }

    /// <summary>
    /// 类型
    /// </summary>
    public enum SensitiveType
    {
        IdNumber,
        Name
    }
View Code

相关文章:

  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-06-28
  • 2021-08-28
  • 2022-12-23
  • 2021-11-02
  • 2021-08-11
  • 2022-12-23
相关资源
相似解决方案