I have a class that needs an instance of a HttpClient class, which I want to be instantiated only once i.e. Singleton
public interface IMyClass {}
public class MyClass : IMyClass {
private HttpClient client;
public MyClass(HttpClient client)
{
this.client = client;
}
}
IUnityContainer container = new UnityContainer();
container.RegisterType<IMyClass, MyClass>();
var httpClient = new HttpClient();
How can I register the httpClient instance as a singleton to my MyClass can use it?