自定义属性
/// <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 }