如何在 Mono 中获取 class 属性?
How to get class attributes in Mono?
我想在 C# 代码中使用属性,这些属性将在我的 使用 Mono 的项目中运行。
可以从 Mono 运行时获取 class 属性吗?以及如何,如果可能的话?
一点解释:
这是我的 class 属性:
[SomeAttribute]
public class SomeClass { /* ... */ }
在我的 C++ 代码中的某处,我启动了 Mono 并使用此 class 加载程序集。
在 C++ 代码中,我想发现此 SomeClass
的属性并执行一些操作。那我该怎么做呢? Mono 能说出这个 class 中使用了哪些属性吗?
从 C++ 端执行此操作将很困难,因此您可能想要做的是从 C# 中正常获取属性 class:
typeof(SomeType).GetAttributes()
然后从您的 C++ 代码中调用一个函数来实际访问该信息。
我想在 C# 代码中使用属性,这些属性将在我的 使用 Mono 的项目中运行。 可以从 Mono 运行时获取 class 属性吗?以及如何,如果可能的话?
一点解释:
这是我的 class 属性:
[SomeAttribute]
public class SomeClass { /* ... */ }
在我的 C++ 代码中的某处,我启动了 Mono 并使用此 class 加载程序集。
在 C++ 代码中,我想发现此 SomeClass
的属性并执行一些操作。那我该怎么做呢? Mono 能说出这个 class 中使用了哪些属性吗?
从 C++ 端执行此操作将很困难,因此您可能想要做的是从 C# 中正常获取属性 class:
typeof(SomeType).GetAttributes()
然后从您的 C++ 代码中调用一个函数来实际访问该信息。