My application has two C# libraries, Foo.dll and Baz.dll. Foo declares class FooActuator, which is directly referenced by Baz. I want to break this dependency by making Baz declare an interface IActuator, and have a controller that instantiates the proper implementation of IActuator and sends to Baz.
The problem is, there are a bunch of classes in this scenario, and I don't want to write an adapter all the time. I'm looking for something like this:
FooActuator real = new FooActuator();
IActuator adapter = BuildAdapter<IActuator>(real); // generates adapter for me
Baz.Process(adapter);
Is there a library or .NET feature that provides this? I wish for something that I can copy or extend (ie already does some class and assembly generation), rather than using System.Reflection.Emit from scratch.
Aucun commentaire:
Enregistrer un commentaire