I have used Data Annotations in my project, but in the universal app, it shows an error for there is no namespace for DataAnnotations.
Is "using System.ComponentModel.DataAnnotations" supported in Unversal App ?
I have used Data Annotations in my project, but in the universal app, it shows an error for there is no namespace for DataAnnotations.
Is "using System.ComponentModel.DataAnnotations" supported in Unversal App ?
看起来不像。 根据他们的路线图, 您必须向下滚动到底部表格才能看到它适用于除手机以外的所有平台。:(
是的,它在 Windows 通用应用程序中得到支持,示例代码:
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
namespace SystematixIndia.Universal.Extensions
{
/// <summary>
/// Provides extensions for the <see cref="Enum" /> class.
/// </summary>
public static class EnumExtensions
{
/// <summary>
/// Gets the display name attribute as a string
/// </summary>
/// <param name="en">The enum.</param>
/// <returns>The display name attribute as a string</returns>
public static string ToDisplayNameAttribute(this Enum en)
{
return en.GetType().GetMember(en.ToString()).First().GetCustomAttribute<DisplayAttribute>().GetName();
}
}
}