I have an application that is structured as follows:
- Class A with certain methods exposed
- Class B that basically acts as the command line interface, calling the exposed methods of an instance of class A
Class B's constructor takes an instance of class A as an argument and works with that instance from then on.
public class B
{
private A ainstance
public B(A ainstance)
{
this.ainstance = ainstance;
}
}
class Program
{
void Main()
{
var x = new A();
var y = new B(x);
}
}
This structure has worked fine so far. Now however I need to implement an API so that the same operations can be performed on A from a web interface. I chose to use .NET Core for the API, and have implemented most of it. My plan was to add a reference for the API project to the original project and then call the startup method from my Main(), once gain passing the instance of class A as an argument. This doesn't work. Visual Studio refuses to add the reference for reasons unknown.
Is there a way to implement my original idea? If not then ideas for an alternative structure would be greatly appreciated.