So right now I am using this line of code to register a service on my app:
services.AddSingleton<IDefaultService, DefaultService>();
I was wondering if there is a way to "mimic" this behavior without using Dependency Injection extension? And if there is how?
So I know that static classes are created once when the app is built/run, so this is a behavior I want. How can I assure that there is no concurrent usage of the service at the same time?
public static class DefaultServiceRegistry {
public static DefaultService DefaultServiceInstance { get; set; }
static DefaultServiceRegistry ()
{
DefaultServiceInstance = new DefaultService ();
}
}