samedi 16 mars 2019

Is it possible to use Custom Attributes to enforce a method signature

I'm looking to use reflection in my rules engine and I'm thinking of using CustomAttributes to access the methods in my class (methods are the "rules" for the engine).

I am wondering if there is some way to enforce that a method follows a certain signature.

[RuleAttribute(typeof(long))]
public double NumericRule(string key, long source, long target)
{
  //Implementation
}

Is there a way to do this? Obviously only a single method will have this exact signature so no issues with multiple methods. Just wondering if there's a way of enforcing this?

Thanks.





Aucun commentaire:

Enregistrer un commentaire