private void RegisterNoSqlConnectors() { AssemblyUtils.GetAttribute <NoSqlConnectorAttribute>().ForEach(t => { ContainerBuilder.RegisterType(t).InstancePerDependency(); }); }
private Registry BuildRegistry() { var registry = new Registry(); AssemblyUtils.GetAttribute <SchedulerJobTaskAttribute>().ForEach(t => { try { var attr = t.GetCustomAttribute <SchedulerJobTaskAttribute>(); var job = _neonManager.Resolve(t) as IJobSchedulerTask; _logger.LogInformation( $"Adding Job {t.Name} StartNow {attr.StartNow} every {attr.Seconds} seconds"); var schedule = registry.Schedule(() => job.Execute()).WithName(t.Name); if (attr.StartNow) { schedule.ToRunNow().AndEvery(attr.Seconds).Seconds(); } else { schedule.ToRunEvery(attr.Seconds).Seconds(); } _jobs.Add(job); } catch (Exception ex) { _logger.LogError($"Error during add job {t.Name} => {ex}"); } }); return(registry); }
private void ScanEventCollectionNames() { AssemblyUtils.GetAttribute <EventsCollectionAttribute>().ForEach(t => { _eventsCollectionNames.Add(GetCollectionName(t), t); }); }
private void RegisterScriptModules() { _logger.Debug($"Scan for Script Modules"); AssemblyUtils.GetAttribute <ScriptModuleAttribute>().ForEach(m => { _logger.Debug($"Registering Script module {m.Name}"); ContainerBuilder.RegisterType(m).SingleInstance(); }); }
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime) { app.UseDefaultFiles(); app.UseStaticFiles(); appLifetime.ApplicationStopped.Register(async() => await Program.ArgonManager.Shutdown()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseCors("AllowOrigin"); //app.UseHttpsRedirection(); if (_config.EngineConfig.UseSwagger) { _logger.LogInformation($"Configuring Swagger on /swagger/ endpoint"); _logger.LogInformation($"Configuring ReDoc on /redoc/ endpoint"); app.UseOpenApi(); // serve OpenAPI/Swagger documents app.UseSwaggerUi3(settings => settings.Path = "/swagger"); app.UseReDoc(settings => settings.Path = "/redoc"); } app.UseWebSockets(); AssemblyUtils.GetAttribute <WebSocketHubAttribute>().ForEach(t => { var wsAttr = t.GetCustomAttribute <WebSocketHubAttribute>(); _logger.LogInformation($"Registering websocket path {wsAttr.Path} to {t.Name}"); app.MapWebSocketManager(wsAttr.Path, ApplicationContainer.Resolve(t) as WebSocketHandler); }); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); await Program.ArgonManager.Start(); }
private void RegisterComponents() { _logger.Debug($"Scan for Components"); AssemblyUtils.GetAttribute <NeonComponentAttribute>().ForEach(c => { _containerBuilder.RegisterType(c).As(AssemblyUtils.GetInterfaceOfType(c)).As(c).SingleInstance(); ScanForComponentsCommands(c); }); }
private void RegisterWebSockets() { _logger.Debug($"Scan for WebSockets hub"); AssemblyUtils.GetAttribute <WebSocketHubAttribute>().ForEach(w => { _logger.Debug($"Registering WebSocket {w.Name}"); _containerBuilder.RegisterType(w).SingleInstance(); }); }
private void ScanTypes() { _logger.Debug($"Scan for services"); AssemblyUtils.GetAttribute <ArgonServiceAttribute>().ForEach(s => { _logger.Debug($"Registering service {s.Name}"); _containerBuilder.RegisterType(s).As(AssemblyUtils.GetInterfaceOfType(s)).SingleInstance(); AvailableServices.Add(s); }); }
public Task <bool> Start() { AssemblyUtils.GetAttribute <NoSqlConnectorAttribute>().ForEach(t => { var attr = t.GetCustomAttribute <NoSqlConnectorAttribute>(); _nosqlConnectors.Add(attr.Name, t); _logger.LogInformation($"Adding NoSql connector {attr.Name} [{t.Name}]"); }); return(Task.FromResult(true)); }
public List <Module> ScanModules() { var result = new List <Module>(); AssemblyUtils.GetAttribute <RegistrationModuleAttribute>().ForEach(m => { var module = (Module)Activator.CreateInstance(m); result.Add(module); }); return(result); }
private void RegisterWebHooks() { _logger.Debug($"Scan for Web Hooks Receivers"); AssemblyUtils.GetAttribute <WebHookReceiverAttribute>().ForEach(r => { var attr = r.GetCustomAttribute <WebHookReceiverAttribute>(); _logger.Debug($"Registering provider {attr.ProviderName}"); _webHookReceiverData.Add(new WebHookReceiverData() { ProviderName = attr.ProviderName, ProviderType = r }); }); _containerBuilder.Register(e => _webHookReceiverData).SingleInstance(); }
private void RegisterDeviceDiscovery() { _logger.Debug("Scan for Device discovery services"); AssemblyUtils.GetAttribute <DiscoveryServiceAttribute>().ForEach(a => { var attr = a.GetCustomAttribute <DiscoveryServiceAttribute>(); _logger.Debug($"Registering device discovery listener"); _deviceDiscoveryListeners.Add(new DiscoveryListenerData() { ServiceName = attr.ServiceName, TypeName = a }); }); _containerBuilder.Register(context => _deviceDiscoveryListeners).SingleInstance(); }
private void ScanAvailableComponents() { AssemblyUtils.GetAttribute <NeonComponentAttribute>().ForEach(f => { var attr = f.GetCustomAttribute <NeonComponentAttribute>(); AvailableComponents.Add(new AvailableComponent() { Name = attr.Name, Category = attr.Category, Description = attr.Description, ComponentType = f }); }); _logger.LogInformation($"Available components count: {AvailableComponents.Count}"); }
private void ScanMoviesIndexers() { if (_logger != null) { _logger.LogInformation($"Scan movies indexers"); AssemblyUtils.GetAttribute <MoviesIndexerAttribute>().ForEach(t => { _logger.LogInformation($"Adding {t.Name} in movie indexers"); var attr = t.GetCustomAttribute <MoviesIndexerAttribute>(); _moviesIndexersTypes.Add(attr.Name, new MoviesIndexerData() { IndexerType = t, Name = attr.Name, BaseUrl = attr.BaseUrl }); }); } }
private void RegisterNotifiers() { _logger.Debug("Scan for Notifiers"); AssemblyUtils.GetAttribute <NotifierAttribute>().ForEach(n => { var attr = n.GetCustomAttribute <NotifierAttribute>(); _logger.Debug($"Registering Notifier name {attr.Name} => {n.Name}"); _containerBuilder.RegisterType(n).SingleInstance(); _notifierData.Add(new NotifierData() { Name = attr.Name, NotifierType = n, NotifierConfigType = attr.ConfigType }); }); _containerBuilder.Register(e => _notifierData).SingleInstance(); }
protected override void Load(ContainerBuilder builder) { AssemblyUtils.GetAttribute <DtoMapperAttribute>().ForEach(t => { var attr = t.GetCustomAttribute <DtoMapperAttribute>(); _mapping.Add(new DtoMapObject() { Source = t, Destination = attr.EntityType }); }); builder.Register <IConfigurationProvider>(ctx => new MapperConfiguration(cfg => { _mapping.ForEach(map => { cfg.CreateMap(map.Source, map.Destination).ReverseMap(); }); })); builder.Register <IMapper>(ctx => new Mapper(ctx.Resolve <IConfigurationProvider>(), ctx.Resolve)).InstancePerDependency(); builder.RegisterGeneric(typeof(AbstractDtoMapper <,>)).As(typeof(IDtoMapper <,>)).InstancePerDependency(); base.Load(builder); }
protected override void Load(ContainerBuilder builder) { var singletonServices = new List <Type>(); AssemblyUtils.GetAttribute <SingletonServiceAttribute>().ForEach(singletonServices.Add); singletonServices.ForEach(ss => { var asInterface = AssemblyUtils.GetInterfaceOfType(ss); if (asInterface != null) { builder.RegisterType(ss).As(asInterface).InstancePerLifetimeScope(); } else { builder.RegisterType(ss).AsSelf().InstancePerLifetimeScope(); } }); base.Load(builder); }
private void ScanScriptsModules() { AssemblyUtils.GetAttribute <ScriptModuleAttribute>().ForEach(LoadScriptModule); }