.NET Core / .NET Standard中的PropertyInfo.ReflectedType等效于什么?

编程入门 行业动态 更新时间:2024-10-28 16:28:25
本文介绍了.NET Core / .NET Standard中的PropertyInfo.ReflectedType等效于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

解决方案

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

您可能会像 Nunit。消除对ReflectedType的使用,以为ASP .Net 5提供支持或 AutoFixture。支持CoreCLR ,以获取有关如何修改代码的想法。通常,有效的解决方案是使用 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等效于什么?

本文发布于:2023-11-15 07:46:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1592510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Core   NET   Standard   ReflectedType   PropertyInfo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!