【发布时间】:2015-03-16 22:07:46
【问题描述】:
我有一个 Silverlight 应用程序,我正在使用实体框架和 Ria 服务。
我需要创建一个自定义属性,用于识别某些属性。
例如。 :
public class Person
{
[IsSpecialProperty]
public string PersonProperty { get; set; }
}
public class IsSpecialPropertyAttribute : Attribute
{
}
我将类文件命名为“IsSpecialPropertyAttribute.shared.cs”,以便从客户端访问它。
从客户端,我使用方法:
var attributes = (IsSpecialPropertyAttribute[])Attribute.GetCustomAttributes(memberInfo, typeof(IsSpecialPropertyAttribute));
此方法适用于系统属性,但不适用于我的自定义属性...
知道为什么吗?
这个方法给了我所有其他的属性,但不是我创建的自定义...
var test = Attribute.GetCustomAttributes(memberInfo);
【问题讨论】:
标签: c# reflection data-annotations wcf-ria-services