本文介绍了.NET Core / .NET Standard中的PropertyInfo.ReflectedType等效于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要类似 PropertyInfo.ReflectedType 在整个框架中所做的事情。



到目前为止,我仍无法弄清 PropertyInfo 的整个属性的替代方法是什么

解决方案

.NET Core不支持ReflectedType,就像Microsoft的人所说的那样,有意排除。这个包含指向博客的链接,该链接解释了原因,但现在已被破坏...



您可能会像或,以获取有关如何修改代码的想法。通常,有效的解决方案是使用 ReflectedType 属性删除所有内容,而是保留并使用对获得类型的对象(反射对象)的引用。 / p>

I need something like what PropertyInfo.ReflectedType does in the full framework.

For now I've been not able to figure out what can be the alternative to the whole property of PropertyInfo.

解决方案

ReflectedType is not supported in .NET Core and was "intentionally excluded" as guys from Microsoft says. This question on github contains a link to blog that explains the reason but is broken right now...

You may look on PRs like Nunit. Eliminate use of ReflectedType in preparation for ASP .Net 5 support or AutoFixture. Support for CoreCLR to get ideas how to adapt your code. In general, the working solution is to remove all using of ReflectedType property and instead hold and use the reference to the the object for which the type was got (reflected object).

这篇关于.NET Core / .NET Standard中的PropertyInfo.ReflectedType等效于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 20:20