public async Task RunAsync(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); Configuration configuration = new Configuration(); DefaultConfigurationLoader.Load(configuration); ApplicationTriggerConfigurationLoader.Load(configuration, taskInstance.TriggerDetails as ApplicationTriggerDetails); ApplicationTriggerDetails triggerDetails = taskInstance.TriggerDetails as ApplicationTriggerDetails; DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); DeviceInformation device = devices.Where(d => d.EnclosureLocation != null).FirstOrDefault(d => d.EnclosureLocation.Panel == Panel.Back); if (device == null) { device = devices.FirstOrDefault(); } captureService = new CaptureService(configuration.Interval, configuration.Delay, device); captureService.ExceptionHandler += OnCaptureException; captureService.TryStartIfNotStopped(); IHttpHandler httpHandler = new AuthenticationHttpHandler(configuration.AuthenticationToken, this); server = new HttpServer(httpHandler); await server.StartAsync(configuration.Port); }
private static void Migrate() { IConfigurationLoader configurationLoader = new DefaultConfigurationLoader(); ICmsConfiguration cmsConfiguration = configurationLoader.LoadCmsConfiguration(); IVersionChecker versionChecker = new VersionCheckerStub(); DefaultMigrationRunner runner = new DefaultMigrationRunner(new DefaultAssemblyLoader(), cmsConfiguration, versionChecker); runner.MigrateStructure(descriptors); }
public void LaunchScheduler(KayakOptions options) { // okay the default delegate kinds sucks because if the user's program doesn't // explicitly call stop the thread essentially hangs, becaues the event loop // frame never returns, it's just waiting on another task. // // something of a halting problem. // would be better if scheduler just stopped when no more callbacks were queued. // // for now, you should use gate if you don't provide a delegate. scheduler and process args // are passed in via env. call stop eventually, or be okay with your program never terminating var kayakDelegate = new KayakDelegateLoader().Load(options.KayakConfiguration) ?? new DefaultKayakDelegate(); var scheduler = KayakScheduler.Factory.Create(kayakDelegate); scheduler.Post(() => kayakDelegate.OnStart(scheduler, options.RemainingArguments)); var gateOptions = options.GateOptions; if (gateOptions != null) { var gateConfiguration = gateOptions.GateConfiguration; var listenEndPoint = gateOptions.ListenEndPoint ?? new IPEndPoint(IPAddress.Any, 8000); var context = new Dictionary <string, object>() { { "kayak.ListenEndPoint", listenEndPoint }, { "kayak.Arguments", options.RemainingArguments } }; var config = DefaultConfigurationLoader.LoadConfiguration(gateConfiguration); if (config == null) { throw new Exception("Could not load Gate configuration from configuration string '" + gateConfiguration + "'"); } var app = AppBuilder.BuildConfiguration(config); var server = KayakServer.Factory.CreateGate(app, scheduler, context); scheduler.Post(() => { Console.WriteLine("kayak: binding gate app to '" + listenEndPoint + "'"); server.Listen(listenEndPoint); }); } // blocks until Stop is called scheduler.Start(); }
public void ShoudlLoad_DefaultConfigurationSection_Successfully() { var service = new DefaultConfigurationLoader(); var configuration = service.LoadConfig <DefaultConfigurationSection>(); Assert.IsNotNull(configuration); Assert.IsNotNull(configuration.Database); Assert.AreEqual(configuration.Database.DatabaseType, DatabaseType.MsSql2008); Assert.AreEqual(configuration.Database.ConnectionStringName, "BetterModulesTests"); Assert.AreEqual(configuration.Database.SchemaName, "dbo"); }
public void ShoudlTryLoad_DefaultConfigurationSection_Successfully() { var service = new DefaultConfigurationLoader(); var configuration = service.TryLoadConfig<DefaultConfigurationSection>(); Assert.IsNotNull(configuration); Assert.IsNotNull(configuration.Database); Assert.AreEqual(configuration.Database.DatabaseType, DatabaseType.MsSql2008); Assert.AreEqual(configuration.Database.ConnectionStringName, "BetterModulesTests"); Assert.AreEqual(configuration.Database.SchemaName, "dbo"); }
private string GetServerUrl() { var serverUrl = string.Empty; var configurationLoader = new DefaultConfigurationLoader(); var configuration = configurationLoader.LoadCmsConfiguration(); if (!string.IsNullOrEmpty(configuration.WebSiteUrl) && configuration.WebSiteUrl.ToLower() != "auto") { serverUrl = configuration.WebSiteUrl.ToLower().TrimEnd('/'); } return serverUrl; }
private string GetServerUrl() { var serverUrl = string.Empty; var configurationLoader = new DefaultConfigurationLoader(); var configuration = configurationLoader.LoadCmsConfiguration(); if (!string.IsNullOrEmpty(configuration.WebSiteUrl) && configuration.WebSiteUrl.ToLower() != "auto") { serverUrl = configuration.WebSiteUrl.ToLower().TrimEnd('/'); } return(serverUrl); }
/// <summary> /// Creates the configured BetterCMS root dependencies container. /// </summary> /// <returns>The container builder.</returns> public static ContainerBuilder InitializeContainer() { IConfigurationLoader configurationLoader = new DefaultConfigurationLoader(); ICmsConfiguration cmsConfiguration = configurationLoader.LoadCmsConfiguration(); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterInstance(configurationLoader).As <IConfigurationLoader>().SingleInstance(); builder.RegisterInstance(cmsConfiguration).As <ICmsConfiguration>().SingleInstance(); builder.RegisterType <DefaultCmsHost>().As <ICmsHost>().SingleInstance(); builder.RegisterType <ApiContext>().AsSelf().SingleInstance(); builder.RegisterType <DefaultSessionFactoryProvider>().As <ISessionFactoryProvider>().SingleInstance(); builder.RegisterType <DefaultAssemblyLoader>().As <IAssemblyLoader>().SingleInstance(); builder.RegisterType <DefaultAssemblyManager>().As <IAssemblyManager>().SingleInstance(); builder.RegisterType <DefaultUnitOfWorkFactory>().As <IUnitOfWorkFactory>().SingleInstance(); builder.RegisterType <DefaultModulesRegistration>().As <IModulesRegistration>().SingleInstance(); builder.RegisterType <DefaultMappingResolver>().As <IMappingResolver>().SingleInstance(); builder.RegisterType <DefaultWorkingDirectory>().As <IWorkingDirectory>().SingleInstance(); builder.RegisterType <DefaultCmsControllerFactory>().SingleInstance(); builder.RegisterType <DefaultEmbeddedResourcesProvider>().As <IEmbeddedResourcesProvider>().SingleInstance(); builder.RegisterType <DefaultHttpContextAccessor>().As <IHttpContextAccessor>().SingleInstance(); builder.RegisterType <DefaultControllerExtensions>().As <IControllerExtensions>().SingleInstance(); builder.RegisterType <DefaultCommandResolver>().As <ICommandResolver>().InstancePerLifetimeScope(); builder.RegisterType <DefaultUnitOfWork>().As <IUnitOfWork>().InstancePerLifetimeScope(); builder.RegisterType <DefaultRepository>().As <IRepository>().InstancePerLifetimeScope(); builder.RegisterInstance(new DefaultRouteTable(RouteTable.Routes)).As <IRouteTable>().SingleInstance(); builder.RegisterType <PerWebRequestContainerProvider>().InstancePerLifetimeScope(); builder.RegisterType <DefaultVersionChecker>().AsImplementedInterfaces().SingleInstance(); builder.RegisterType <DefaultMigrationRunner>().AsImplementedInterfaces().SingleInstance(); RegisterCacheService(cmsConfiguration, builder); RegisterStorageService(cmsConfiguration, builder); return(builder); }
/// <summary> /// Creates the configured BetterCMS root dependencies container. /// </summary> /// <returns>The container builder.</returns> public static ContainerBuilder InitializeContainer() { IConfigurationLoader configurationLoader = new DefaultConfigurationLoader(); ICmsConfiguration cmsConfiguration = configurationLoader.LoadCmsConfiguration(); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterInstance(configurationLoader).As<IConfigurationLoader>().SingleInstance(); builder.RegisterInstance(cmsConfiguration).As<ICmsConfiguration>().SingleInstance(); builder.RegisterType<DefaultCmsHost>().As<ICmsHost>().SingleInstance(); builder.RegisterType<DefaultSessionFactoryProvider>().As<ISessionFactoryProvider>().SingleInstance(); builder.RegisterType<DefaultAssemblyLoader>().As<IAssemblyLoader>().SingleInstance(); builder.RegisterType<DefaultAssemblyManager>().As<IAssemblyManager>().SingleInstance(); builder.RegisterType<DefaultUnitOfWorkFactory>().As<IUnitOfWorkFactory>().SingleInstance(); builder.RegisterType<DefaultModulesRegistration>().As<IModulesRegistration>().SingleInstance(); builder.RegisterType<DefaultMappingResolver>().As<IMappingResolver>().SingleInstance(); builder.RegisterType<DefaultWorkingDirectory>().As<IWorkingDirectory>().SingleInstance(); builder.RegisterType<DefaultCmsControllerFactory>().SingleInstance(); builder.RegisterType<DefaultEmbeddedResourcesProvider>().As<IEmbeddedResourcesProvider>().SingleInstance(); builder.RegisterType<DefaultHttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance(); builder.RegisterType<DefaultControllerExtensions>().As<IControllerExtensions>().SingleInstance(); builder.RegisterType<DefaultCommandResolver>().As<ICommandResolver>().InstancePerLifetimeScope(); builder.RegisterType<DefaultUnitOfWork>().As<IUnitOfWork>().InstancePerLifetimeScope(); builder.RegisterType<DefaultRepository>().As<IRepository>().InstancePerLifetimeScope(); builder.RegisterInstance(new DefaultRouteTable(RouteTable.Routes)).As<IRouteTable>().SingleInstance(); builder.RegisterType<PerWebRequestContainerProvider>().InstancePerLifetimeScope(); builder.RegisterType<DefaultMigrationRunner>().AsImplementedInterfaces().SingleInstance(); RegisterCacheService(cmsConfiguration, builder); RegisterStorageService(cmsConfiguration, builder); return builder; }