public virtual IEnumerable <Attribute> GetAttributes( PropertyInfo propertyInfo) { return(this._discoveredAttributes.GetOrAdd(propertyInfo, (Func <PropertyInfo, IEnumerable <Attribute> >)(pi => { PropertyDescriptor property = AttributeProvider.GetTypeDescriptor(pi.DeclaringType).GetProperties()[pi.Name]; IEnumerable <Attribute> attributes1 = property != null ? property.Attributes.Cast <Attribute>() : pi.GetCustomAttributes <Attribute>(true); ICollection <Attribute> attributes2 = (ICollection <Attribute>) this.GetAttributes(pi.PropertyType); if (attributes2.Count > 0) { attributes1 = attributes1.Except <Attribute>((IEnumerable <Attribute>)attributes2); } return (IEnumerable <Attribute>)attributes1.ToList <Attribute>(); }))); }
public virtual IEnumerable <Attribute> GetAttributes(Type type) { List <Attribute> attrs = new List <Attribute>(AttributeProvider.GetTypeDescriptor(type).GetAttributes().Cast <Attribute>()); foreach (Attribute attribute in type.GetCustomAttributes <Attribute>(true).Where <Attribute>((Func <Attribute, bool>)(a => { if (a.GetType().FullName.Equals("System.Data.Services.Common.EntityPropertyMappingAttribute", StringComparison.Ordinal)) { return(!attrs.Contains(a)); } return(false); }))) { attrs.Add(attribute); } return((IEnumerable <Attribute>)attrs); }