Add attribute to all properties of a class and its descendants

375 views Asked by At

I'm working with workflow foundation and I have a base CodeActivity that is super class of all my activities.

I'm adding Category as 'input' or 'output' to properties to ease the work of those using the activities. Example:

public class MyActivity : MyBaseActivity
{
    [Category("Input")]
    public InArgument<string> User { get; set; }

    [Category("Input")]
    public InArgument<int> Department { get; set; }

    [Category("Output")]
    public OutArgument<string> Supervisor { get; set; }

    // ...
}

All my InArgument's will have category set as input, as well as OutArguments.

There is a way of doing this without writting [Category("Input")] to every single property?

I've tried by an inherited version of InArgument:

[Category("Input")]
public sealed class ActivityInput<T> : InArgument<T> { }

But InArgument is sealed so is not possible that way.

0

There are 0 answers