views:

34

answers:

1

Hi,

I am wondering if there exists a built in class which provides a functionality similar to that of TypeDescriptor, except for method reflection rather than property.

I require this to dynamically create a context menu based on flagged methods within an object

e.g.

    [ContextMenuItem(true)]
    [DisplayName("Do Something")]
    public override void DoSomthing()
    {
        ...
    }

I'm starting to build one myself as I haven't found one anywhere, but it always pays to ask :)

+1  A: 

You could use the DescriptionAttribute and always look a for a particular string?

[Description("SPECIAL")]
void Doit(){}

But it's pretty easy to create your attribute type and then reflect for it, this way you can type your own parameters on to it.

Preet Sangha
Yea, I'm starting to go down the creating attributes path already (I've already done a lot of them for use with PropertyGrid). However there's no point reinventing the wheel (or at least part of it) if it is around already.
Courtney de Lautour