protected virtual IRuntimePlugin[] LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container)
        {
            var plugins = container.Resolve<IDictionary<string, IRuntimePlugin>>().Values.AsEnumerable();

            var pluginLoader = container.Resolve<IRuntimePluginLoader>();
            plugins = plugins.Concat(configurationProvider.GetPlugins().Where(pd => (pd.Type & PluginType.Runtime) != 0).Select(pd => LoadPlugin(pluginLoader, pd)));

            return plugins.ToArray();
        }
示例#2
0
        private static IRuntimePlugin[] LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container)
        {
            var plugins = container.Resolve <IDictionary <string, IRuntimePlugin> >().Values.AsEnumerable();

            var pluginLoader = container.Resolve <IRuntimePluginLoader>();

            plugins = plugins.Concat(configurationProvider.GetPlugins().Where(pd => (pd.Type & PluginType.Runtime) != 0).Select(pd => LoadPlugin(pluginLoader, pd)));

            return(plugins.ToArray());
        }
        public static IObjectContainer CreateContainer(IRuntimeConfigurationProvider configurationProvider = null)
        {
            var container = new ObjectContainer();

            RegisterDefaults(container);

            if (configurationProvider != null)
            {
                container.RegisterInstanceAs(configurationProvider);
            }

            configurationProvider = configurationProvider ?? container.Resolve <IRuntimeConfigurationProvider>();

            var pluginLoader = container.Resolve <IRuntimePluginLoader>();
            var plugins      = configurationProvider.GetPlugins().Select(pd => LoadPlugin(pluginLoader, pd)).ToArray();

            foreach (var plugin in plugins)
            {
                plugin.RegisterDefaults(container);
            }

            RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();

            foreach (var defaultsProvider in container.Resolve <IDictionary <string, IRuntimeConfigurationDefaultsProvider> >().Values)
            {
                defaultsProvider.SetDefaultConfiguration(runtimeConfiguration);
            }
            configurationProvider.LoadConfiguration(runtimeConfiguration);

#if !BODI_LIMITEDRUNTIME
            if (runtimeConfiguration.CustomDependencies != null)
            {
                container.RegisterFromConfiguration(runtimeConfiguration.CustomDependencies);
            }
#endif

            container.RegisterInstanceAs(runtimeConfiguration);

            if (runtimeConfiguration.TraceListenerType != null)
            {
                container.RegisterTypeAs <ITraceListener>(runtimeConfiguration.TraceListenerType);
            }

            if (runtimeConfiguration.RuntimeUnitTestProvider != null)
            {
                container.RegisterInstanceAs(container.Resolve <IUnitTestRuntimeProvider>(runtimeConfiguration.RuntimeUnitTestProvider));
            }

            foreach (var plugin in plugins)
            {
                plugin.RegisterCustomizations(container, runtimeConfiguration);
            }

            return(container);
        }
示例#4
0
        protected virtual void LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container, RuntimePluginEvents runtimePluginEvents, SpecFlowConfiguration specFlowConfiguration)
        {
            // initialize plugins that were registered from code
            foreach (var runtimePlugin in container.Resolve <IDictionary <string, IRuntimePlugin> >().Values)
            {
                // these plugins cannot have parameters
                runtimePlugin.Initialize(runtimePluginEvents, new RuntimePluginParameters());
            }

            // load & initalize parameters from configuration
            var pluginLoader = container.Resolve <IRuntimePluginLoader>();

            foreach (var pluginDescriptor in configurationProvider.GetPlugins(specFlowConfiguration).Where(pd => (pd.Type & PluginType.Runtime) != 0))
            {
                LoadPlugin(pluginDescriptor, pluginLoader, runtimePluginEvents);
            }
        }
        public static IObjectContainer CreateContainer(IRuntimeConfigurationProvider configurationProvider = null)
        {
            var container = new ObjectContainer();

            RegisterDefaults(container);

            if (configurationProvider != null)
                container.RegisterInstanceAs(configurationProvider);

            configurationProvider = configurationProvider ?? container.Resolve<IRuntimeConfigurationProvider>();

            var pluginLoader = container.Resolve<IRuntimePluginLoader>();
            var plugins = configurationProvider.GetPlugins().Select(pd => LoadPlugin(pluginLoader, pd)).ToArray();
            foreach (var plugin in plugins)
            {
                plugin.RegisterDefaults(container);
            }

            RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();
            foreach (var defaultsProvider in container.Resolve<IDictionary<string, IRuntimeConfigurationDefaultsProvider>>().Values)
            {
                defaultsProvider.SetDefaultConfiguration(runtimeConfiguration);
            }
            configurationProvider.LoadConfiguration(runtimeConfiguration);

#if !BODI_LIMITEDRUNTIME
            if (runtimeConfiguration.CustomDependencies != null)
                container.RegisterFromConfiguration(runtimeConfiguration.CustomDependencies);
#endif

            container.RegisterInstanceAs(runtimeConfiguration);

            if (runtimeConfiguration.TraceListenerType != null)
                container.RegisterTypeAs<ITraceListener>(runtimeConfiguration.TraceListenerType);

            if (runtimeConfiguration.RuntimeUnitTestProvider != null)
                container.RegisterInstanceAs(container.Resolve<IUnitTestRuntimeProvider>(runtimeConfiguration.RuntimeUnitTestProvider));

            foreach (var plugin in plugins)
            {
                plugin.RegisterCustomizations(container, runtimeConfiguration);
            }

            return container;
        }
示例#6
0
        protected virtual void LoadPlugins(IRuntimeConfigurationProvider configurationProvider, ObjectContainer container, RuntimePluginEvents runtimePluginEvents)
        {
            // initialize plugins that were registered from code
            foreach (var runtimePlugin in container.Resolve<IDictionary<string, IRuntimePlugin>>().Values)
            {
                // these plugins cannot have parameters
                runtimePlugin.Initialize(runtimePluginEvents, new RuntimePluginParameters());
            }

            // load & initalize parameters from configuration
            var pluginLoader = container.Resolve<IRuntimePluginLoader>();
            foreach (var pluginDescriptor in configurationProvider.GetPlugins().Where(pd => (pd.Type & PluginType.Runtime) != 0))
            {
                LoadPlugin(pluginDescriptor, pluginLoader, runtimePluginEvents);
            }
        }