mercredi 29 avril 2015

Call method with custom attribute with 2 or more identifiers through reflection

Say I have the following method with my custom attribute ApprovalIdentifierAttribute:

// FormState is an enum
// WorkflowType is an enum
// There will be multiple methods like this, where the FormState is Draft
// but the WorkflowType is different.
[ApprovalIdentifier(FormState.Draft, WorkflowType.PriceApproval)]
public static void SetDraftReviewers()
{
    SetDraftReviewer(new[] {"Lucy", "Stan"});
}

I want to be able to have a collection of all methods with this attribute and then use FormState & WorkflowType to identify which method I want to invoke.

How would I call the method through reflection on this condition?
Is it possible?





Aucun commentaire:

Enregistrer un commentaire