.net 核心等效于在程序集上的 GetCustomAttribute? [英] .net core equivalent for GetCustomAttribute on assembly?

查看:19
本文介绍了.net 核心等效于在程序集上的 GetCustomAttribute?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I cannot find a .net core equivalent for calling GetCustomAttributes on an assembly object. I see there is CustomAttributes property, but this doesn't return instances of the custom attributes, but rather metadata about the attributes. How can I retrieve the actual attribute instance?

推荐答案

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

There's a GetCustomAttributes extension method. Just add using System.Reflection.

这篇关于.net 核心等效于在程序集上的 GetCustomAttribute?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆