/// <summary> /// init, must called to setup windsor container /// </summary> public void Init(Action action, bool enablePlugins) { if (!gate.TryEnter()) { return; } try { _container = new ServiceContainer(); if (action != null) { action.Invoke(); } _container.ComponentCreated += _container_ComponentCreated; if (enablePlugins) { PluginBootstrapper pluginBootstrapper = PluginBootstrapper.Instance; pluginBootstrapper.InitializePlugins(pluginBootstrapper.GetPluginDefinitions()); } } catch (Exception ex) { throw new KissException("ServiceLocator init failed!", ex); } }
public void Plugin_WithoutInitializerDefinition_IsNotInvoked() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(PlugIn3) }); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder); invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); Assert.That(PlugIn3.WasInitialized, Is.False); }
public void AutoInitializePlugin_IsInvoked() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(PlugIn2) }); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder); PlugIn2.WasInitialized = false; invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); Assert.That(PlugIn2.WasInitialized, Is.True); }
public ChannelActor(ChannelConfiguration config) { this.Config = config; this._Bootstrapper = new PluginBootstrapper(config); Receive <MSG.WhisperMessage>(msg => WhisperMessage(msg)); Receive <MSG.BroadcastMessage>(msg => BroadcastMessage(msg)); Receive <MSG.Currency.AddCurrencyMessage>(msg => AddCurrency(msg)); Receive <MSG.Currency.MyCurrencyMessage>(msg => ReportCurrency(msg)); Receive <OnNewFollowersDetectedArgs>(args => _NewFollower.Tell(args, this.Self)); Receive <MSG.NotifyChannelOfConfigurationUpdate>(msg => this.Config = config); //Receive<MSG.GetFeatureFromChannel>(msg => Sender.Tell(GetFeature(msg.FeatureType))); Self = Context.Self; }
public void Plugins_CanBeInitialized_FromConfiguration() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(typeof(PlugIn1).Assembly, new[] { typeof(PlugIn3) }); EngineSection config = CreateConfiguration(new[] { new PluginInitializerElement { Name = "ignored", Type = typeof(PlugIn3).AssemblyQualifiedName } }, null); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder, config); invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); Assert.That(PlugIn3.WasInitialized, Is.True); }
public void AutoInitialized_PluginInitializers_CanBeRemoved_UsingConfiguration_ByType() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(typeof(PlugIn1).Assembly, new[] { typeof(PlugIn2) }); EngineSection config = CreateConfiguration(null, new[] { new PluginInitializerElement { Name = "ignored", Type = typeof(PlugIn2).AssemblyQualifiedName } }); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder, config); invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); Assert.That(PlugIn2.WasInitialized, Is.False); }
protected void Application_Start() { Bootstrapper.Install(); PluginBootstrapper.Initialize(); Injector.Inject(); var container = ServiceLocator.Current.GetInstance <Castle.Windsor.IWindsorContainer>(); container.Register(AllTypes.Of <IController>().FromAssembly(Assembly.GetExecutingAssembly()) .LifestyleTransient()); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions <BotConfiguration> botConfig, IActorRef channelManagerActor, ILoggerFactory loggerFactory) { // cheer 142 cpayette 4/10/2019 // cheer 300 tbdgamer 4/10/2019 var logger = loggerFactory.CreateLogger("Startup"); logger.LogDebug($"Our Auth0 Domain is: {Configuration["Auth0:Domain"]}"); BotConfiguration = botConfig.Value; channelManagerActor.Tell(new RejoinChannels()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseRouting(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseAuthorization(); // Configure plugged in features PluginBootstrapper.ServiceProvider = app.ApplicationServices; PluginBootstrapper.InitializeFeatures(app); app.UseEndpoints(routes => { routes.MapHub <LoggerHub>("/loggerhub"); routes.MapHub <UserActivityHub>("/useractivityhub"); MapExternalHubs(routes); routes.MapHealthChecks("/health"); routes.MapRazorPages(); routes.MapDefaultControllerRoute(); routes.MapBlazorHub(); routes.MapFallbackToPage("/Index"); }); }
public void Initializers_AreExecuted_AfterException() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(ThrowingPlugin1), typeof(PlugIn2) }); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder); PlugIn2.WasInitialized = false; ThrowingPlugin1.Throw = true; PluginInitializationException ex = ExceptionAssert.Throws <PluginInitializationException>(delegate { invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); }); ThrowingPlugin1.Throw = false; Assert.That(PlugIn2.WasInitialized, Is.True); }
public void InnerException_IsInnerException_OfInitializationException() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(ThrowingPlugin1), typeof(PlugIn2) }); mocks.ReplayAll(); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder); PlugIn2.WasInitialized = false; ThrowingPlugin1.Throw = true; PluginInitializationException ex = ExceptionAssert.Throws <PluginInitializationException>(delegate { invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); }); ThrowingPlugin1.Throw = false; Assert.That(ex.InnerException, Is.TypeOf(typeof(SomeException))); Assert.That(ex.Message.Contains("ThrowingPlugin1 isn't happy.")); }
public void InnerExceptions_AreAdded_ToInitializationException() { ITypeFinder typeFinder = new Fakes.FakeTypeFinder(new[] { typeof(ThrowingPlugin1), typeof(PlugIn2), typeof(ThrowingPlugin2) }); PluginBootstrapper invoker = new PluginBootstrapper(typeFinder); PlugIn2.WasInitialized = false; ThrowingPlugin1.Throw = true; ThrowingPlugin2.Throw = true; PluginInitializationException ex = ExceptionAssert.Throws <PluginInitializationException>(delegate { invoker.InitializePlugins(null, invoker.GetPluginDefinitions()); }); ThrowingPlugin1.Throw = false; ThrowingPlugin2.Throw = false; Assert.That(ex.InnerExceptions.Length, Is.EqualTo(2)); Assert.That(ex.Message.Contains("ThrowingPlugin1 isn't happy.")); Assert.That(ex.Message.Contains("ThrowingPlugin2 is really mad.")); }