自定义属性类实例的比较,默认的Attribute.Match 只是简单的调用了Equal方法,我们可以重写此Match方法来精确定义对Attribute的比较。

代码:

自定义属性类:

自定义属性Attribute(二)自定义属性Attribute(二)代码

目标类:

 

 

自定义属性Attribute(二)自定义属性Attribute(二)代码
  [Accounts(EnumAccounts.Savings)]
internal sealed class ChildAccount
{

}

[Accounts(EnumAccounts.Savings
| EnumAccounts.Brokerage | EnumAccounts.Checking)]
internal sealed class AdultAccount
{

}

 

 

 

 

调用:

自定义属性Attribute(二)自定义属性Attribute(二)代码

相关文章:

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