コード例 #1
0
        private static void InitializeServiceLocator(ExtensionConfigContext context)
        {
            var bootstrapperCollector = new BootstrapperCollector();
            var bootstrappers         = bootstrapperCollector.GetBootstrappers();

            if (bootstrappers.Count == 0)
            {
                throw new BootstrapperNotFoundException("No bootstrapper instances had been recognized.");
            }

            var modules = new List <Module>();

            foreach (var bootstrapper in bootstrappers)
            {
                var instance = (IBootstrapper)Activator.CreateInstance(bootstrapper);
                modules.AddRange(instance.CreateModules());
            }
            InjectConfiguration.Initialize(modules.ToArray());
        }
コード例 #2
0
        private static List <Module> GetModules()
        {
            var bootstrapperCollector = new BootstrapperCollector();
            var bootstrappers         = bootstrapperCollector.GetBootstrappers();

            if (bootstrappers.Count == 0)
            {
                throw new BootstrapperNotFoundException("No bootstrapper instances had been recognized.");
            }

            var modules = new List <Module>();

            foreach (var bootstrapper in bootstrappers)
            {
                var instance = (IBootstrapper)Activator.CreateInstance(bootstrapper);
                modules.AddRange(instance.CreateModules());
            }

            return(modules);
        }