I have two processes (A and B), both have a method Foo(SomeClass paramA, SomeOtherClass paramB). The processes communicate using Windows Pipes (not WCF) and can send and receive messages of type:
public class PipeMessageArgs
{
public PipeMessageArgs(string i_MethodName, List<object> i_Args)
{
MethodName = i_MethodName;
Args = i_Args;
}
public string MethodName { get; private set; }
public List<object> Args { get; private set; }
}
When calling Foo on A, I want to invoke Foo on B, with the same values.
Currently, I do it like this:
var args = new List<object> { paramA, paramB };
PushMessage(new PipeMessageArgs(Helpers.GetCurrentMethod(), args));
But as you can see, I have to manually create a list of parameters for each call so if I forget a parameter or get the order wrong, things will not work. Given that I cannot use reflection to get the values, and I do not want to use the profiler (performance is an issue), what is the best way to make it more generic?
Aucun commentaire:
Enregistrer un commentaire