如何在C#中缓存反射
你好呀 我对反射非常熟悉,我已经看过大量示例,我知道它是如何工作的以及我们可以使用它的目的。但我没有得到任何缓存反射的例子,我也不知道这是什么意思。不知何故,我必须在我正在做的项目中使用反射缓存。
因此,如果有人可以简要解释这个概念并给出一些示例,我将不胜感激,也将不胜感激现有示例的链接。并请描述属性的反射及其缓存。提前致谢。
问候 乌迈尔
Hello there
I am familiar with reflection quite a bit, I have been through loads of examples and I know how it works and for what purpose we can use it. But I didn't get any examples of caching the reflection, neither do I know what does it mean. And somehow I have to use caching of reflection in of the projects that I am doing.
Therefore, I would be obliged if some one can briefly explain this concept as well as give some examples of it, a link to existing examples would also be appreciated. And please also describe the reflection of attributes as well as its caching. Thanks in advance.
Regards
Umair
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以像缓存其他任何东西一样缓存它:
You would cache it like you would anything else:
我建议不要缓存反射(呵呵),因为它(当然)是由运行时完成的。如果您想减少查找时间以及动态调用开销,
无论您做什么:不要过早优化使事情复杂化。
I suggest not caching the reflection (hehe) because it is (of course) done by the runtime. If you mean to reduce lookup time and perhaps dynamic invocation overhead
And whatever you do: don't complicate things by optimizing prematurely.