Is restricting attributes to class or properties doable?

Posted by Will Marcouiller on Stack Overflow See other posts from Stack Overflow or by Will Marcouiller
Published on 2010-05-21T18:02:19Z Indexed on 2010/05/21 18:10 UTC
Read the original article Hit count: 299

I have two custom attributes defined like so:

internal class SchemaAttribute : Attribute {
    internal SchemaAttribute(string schema) {
        Schema = schema;
    }

    internal string Schema { get; private set; }
}

internal class AttributeAttribute : Attribute {
    internal AttributeAttribute(string attribute) {
        Attribute = attribute;
    }

    internal string Attribute { get; private set; }
}

I would like to restrict the SchemaAttribute to classes, and the AttributeAttribute to properties.

Is this doable?

© Stack Overflow or respective owner

Related posts about attributes

Related posts about custom-attributes