static void Main(string[] args) { var logger = new MyLogger(); var factory = new Factory("MyApp", logger); // Auto register types. factory.AutoRegisterTypes(); // Normal singleton bootstrapping... although the lazy singleton isn't instantiated yet. factory.AutoInstantiateSingletons(); // Create an instance. // This will instantiate the lazy singleton at the point when it is requested by the dependency injection system. var myFactoryCreatedObject = factory.CreateInterface<IMyType>(); Console.WriteLine(myFactoryCreatedObject.Message); }
static void Main(string[] args) { var logger = new MyLogger(); var factory = new Factory("MyApp", logger, new Reflection()); // Auto register types. factory.AutoRegisterTypes(); // Auto bootstrap singletons for classes marked as [Singleton]. factory.AutoInstantiateSingletons(); // Create an instance. var myFactoryCreatedObject = factory.CreateInterface<IMyType>(); Console.WriteLine(myFactoryCreatedObject.Message); }
static void Main(string[] args) { var logger = new MyLogger(); var factory = new Factory("MyApp", logger); // Auto register types. factory.AutoRegisterTypes(); // Auto bootstrap singletons for classes marked as [Singleton]. var singletonManager = factory.AutoInstantiateSingletons(); // Start-up startable singletons. singletonManager.Startup(); // Create an instance. var myFactoryCreatedObject = factory.CreateInterface<IMyType>(); Console.WriteLine(myFactoryCreatedObject.Message); // Shutdown startable singletons. singletonManager.Shutdown(); }