public PluginRunner(IServiceProvider externalServiceProvider, IConfigManager cfg) { _externalServiceProvider = externalServiceProvider; _config = cfg; _configAccessors = new Dictionary <INamedVersionedUniqueId, PluginConfigAccessor>(); _config.Extended.Container.Changed += OnConfigContainerChanged; _discoverer = new PluginDiscoverer(); _runningConfig = new RunningConfiguration(this); _requirements = new RunnerRequirements(this); _host = new PluginHost(); // 0 - For creation. _host.PluginCreator = CreatePlugin; // 1 - Before Setup call: plugin is configured. _host.PluginConfigurator = ConfigurePlugin; // 2 - Before Start: plugin is aware of its environment. _host.ServiceReferencesBinder = ConfigureServiceReferences; }
public TestContext( bool handMadeProxy, bool startPlugin, CatchExceptionGeneration catchExceptionsForRealProxy ) { PluginHost = new PluginHost( catchExceptionsForRealProxy ); RealPlugin = new ChoucroutePlugin(); ConsumerPlugin = new ConsumerPlugin( this ); PluginHost.PluginCreator = key => key == PluginPluginId ? (IPlugin)RealPlugin : ConsumerPlugin; PluginHost.ServiceReferencesBinder = newPluginsLoaded => { }; if( handMadeProxy ) { ServiceHost.SetManualProxy( typeof(IChoucrouteService), IChoucrouteServiceHandMadeProxy.CreateProxy() ); } // The proxy is itself a IChoucrouteService. Assert.That( Service is IChoucrouteService ); Assert.That( Service is ServiceProxyBase ); // We check the Running attribute. Assert.That( Service.Status == RunningStatus.Disabled ); Assert.That( PluginProxy == null ); if( startPlugin ) { PluginHost.Execute( ReadOnlyListEmpty<IPluginInfo>.Empty, ReadOnlyListEmpty<IPluginInfo>.Empty, new[] { PluginPluginId } ); Assert.That( PluginProxy.Status == RunningStatus.Started ); Assert.That( Service.Status == RunningStatus.Started ); } }