/// <summary> /// Helper function to initalize the factory. /// </summary> private static SingletonManager InitFactory(Utils.ILogger logger, Factory factory, IReflection reflection) { //todo: all this code should merge into RSG.Factory. factory.AutoRegisterTypes(); var singletonManager = new SingletonManager(logger, factory); factory.Dep(reflection); factory.AddDependencyProvider(singletonManager); var singletonScanner = new SingletonScanner(reflection, logger, singletonManager); singletonScanner.ScanSingletonTypes(); return(singletonManager); }
/// <summary> /// Automatically find and instantiate singletons, classes that are marked with the [Singleton] attribute, or an attribute /// that derives from SingletonAttribute. /// </summary> public ISingletonManager AutoInstantiateSingletons() { var singletonManager = new SingletonManager(logger, this); var singletonScanner = new SingletonScanner(reflection, logger, singletonManager); // Connect the singleton manager to the factory so that it can be used to satisify dependencies. AddDependencyProvider(singletonManager); // Auto register singletons whose types are marked with the Singleton attribute. singletonScanner.ScanSingletonTypes(); // Instantiate singletons. singletonManager.InstantiateSingletons(this); return(singletonManager); }