【问题标题】:.net core equivalent for GetCustomAttribute on assembly?.net 核心等效于程序集上的 GetCustomAttribute?
【发布时间】:2016-11-10 19:42:32
【问题描述】:

我找不到在程序集对象上调用 GetCustomAttributes 的 .net 核心等效项。我看到有 CustomAttributes 属性,但这不会返回自定义属性的实例,而是返回有关属性的元数据。如何检索实际的属性实例?

【问题讨论】:

标签: reflection .net-core


【解决方案1】:

有一个GetCustomAttributes 扩展方法。只需添加using System.Reflection

【讨论】:

  • 不知道为什么......我猜工具仍在预览中......但我无法让 Visual Studio 同意。既然你说这是事实,我决定再试一次,努力,所以我卸载/关闭/重新加载/将一只手放在头上/面向东北,突然视觉工作室说扩展方法确实存在......谢谢!
  • @Adam,一定是我不这样做,所以我仍然看到GetCustomAttributes下的曲线?
  • .NET Core 版本需要 MemberInfo 对象作为第一个参数。我不确定该放什么。
猜你喜欢
  • 1970-01-01
  • 2018-08-22
  • 2017-08-04
  • 2017-08-05
  • 1970-01-01
  • 2020-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多