如何为 .NET Standard 替换 System.ComponentModel.DataAnnotations 的 类?
How to replace the classes of System.ComponentModel.DataAnnotations for .NET Standard?
.NET Standard不支持'System.ComponentModel.DataAnnotations'和'System.Type.Properties',如何保持兼容?
来自 System.ComponentModel.DataAnnotations
命名空间的类型在 the System.ComponentModel.Annotations
package 中,默认情况下未安装在 .Net 标准库中,因此您需要手动安装才能在那里使用它。
如果您的意思是 Type.GetProperties()
,那么该方法作为扩展方法存在于 .Net Core 和 .Net Standard 中。在 .Net Standard 库中,您需要安装 the System.Reflection.TypeExtensions
package。在 .Net Core 应用程序和 .Net Standard 库中,您需要将 using System.Reflection;
添加到源代码中。
.NET Standard不支持'System.ComponentModel.DataAnnotations'和'System.Type.Properties',如何保持兼容?
来自 System.ComponentModel.DataAnnotations
命名空间的类型在 the System.ComponentModel.Annotations
package 中,默认情况下未安装在 .Net 标准库中,因此您需要手动安装才能在那里使用它。
如果您的意思是 Type.GetProperties()
,那么该方法作为扩展方法存在于 .Net Core 和 .Net Standard 中。在 .Net Standard 库中,您需要安装 the System.Reflection.TypeExtensions
package。在 .Net Core 应用程序和 .Net Standard 库中,您需要将 using System.Reflection;
添加到源代码中。