I have a custom attribute that I want to apply to a base abstract class so that I can skip elements that the user does not need to see when displaying the element in HTML. It seems that properties overriding the base class do not inherit attributes.
Does the basic property (abstract or virtual) replace the attributes assigned to the original property?
From the Defination attribute class
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)] public class NoHtmlOutput : Attribute { }
From the abstract class Defination
[NoHtmlOutput] public abstract Guid UniqueID { get; set; }
From the definition of the class of concrete
public override Guid UniqueID{ get{ return MasterId;} set{MasterId = value;}}
From class validation to attribute
Type t = o.GetType(); foreach (PropertyInfo pi in t.GetProperties()) { if (pi.GetCustomAttributes(typeof(NoHtmlOutput), true).Length == 1) continue;
reflection c # abstract-class attributes
Marty Trenouth Mar 25 '10 at 23:00 2010-03-25 23:00
source share