mercredi 1 avril 2020

Create wrapper around interface and get method/paramters called

Lets say I have this interface

public interface ITest
{
    int Property1 { get; set; }
    void Method1();
    string GetMethod1();
    void MethodWithParam(string str);
}

How can I create a wrapper object around this?

And then capture the methods called or paramters and values accessed etc.

For example:

var myWrapper = GetWrapper<ITest>();
myWrapper.Property1 = 7;

How would I be able to using reflection or whatever to know the following:

Paramter name being called and value being set

var data = myWrapper.GetMethod1("Test");

Get method name of "GetMethod1" along with paramaters and then return a value based on that?

Hope makes sense





Aucun commentaire:

Enregistrer un commentaire