public void ReloadingConfigurationShouldNotDuplicateEntries() { var container = new CompositionContainer(); var configurationCatalog = new LoadConfiguration(new DirectoryInfo(_PathToDebugConfiguration), container); configurationCatalog.Load(); var conf = container.GetExportedValue <Configuration>(); var count = conf.Directories.Count; configurationCatalog.Load(); Assert.Equal(count, conf.Directories.Count); Assert.Contains(@"%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu", conf.Directories); }
public void ComposingTwiceIsNotABigDeal() { var container = new CompositionContainer(); var configurationCatalog = new LoadConfiguration(new DirectoryInfo(_PathToDebugConfiguration), container); configurationCatalog.Load(); var conf = container.GetExportedValue <Configuration>(); Assert.Contains(@"%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu", conf.Directories); configurationCatalog.Load(); conf = container.GetExportedValue <Configuration>(); Assert.Contains(@"%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu", conf.Directories); }
public static void Main(string[] args) { LoadConfiguration.Load(); SystemClock.GetInstance(); //new SystemClock(); --Singleton, autorun BuildWebHost(args).Run(); }
public void CanLoadConfigurationFromGlobalAndUserRepositoryUsingShortAndLongName() { var userConfigurationDirectory = "user-configuration".AsNewDirectoryInfo(); var systemConfigurationDirectory = "temp-configuration".AsNewDirectoryInfo(); var systemConfiguration = new SampleConfigurationWithDefaultValues() { Value = 10, SecondValue = 200 }; var userConfiguration = new { Value = 20 }; WriteConfiguration <SampleConfigurationWithDefaultValues>(userConfigurationDirectory, userConfiguration, true); WriteConfiguration <SampleConfigurationWithDefaultValues>(systemConfigurationDirectory, systemConfiguration); var container = new CompositionContainer(); var configurationCatalog = new LoadConfiguration(systemConfigurationDirectory, container); configurationCatalog.AddConfigurationLocation(userConfigurationDirectory); configurationCatalog.Load(); var conf = container.GetExportedValue <SampleConfigurationWithDefaultValues>(); Assert.Equal(20, conf.Value); Assert.Equal(200, conf.SecondValue); }
protected DBConfig() { var config = LoadConfiguration.Load().GetConfiguration; _relational = config["ConnectionStrings:RelationalSchema"]; _dimensional = config["ConnectionStrings:DimensionalSchema"]; _eventStore = config["ConnectionStrings:EventstoreSchema"]; }
public RabbitMqConfigParams() { var config = LoadConfiguration.Load().GetConfiguration; Username = config["RabbitMQ:Username"]; Password = config["RabbitMQ:Password"]; Hostname = config["RabbitMQ:Hostname"]; Port = int.Parse(config["RabbitMQ:Port"]); }
public void ShouldIgnoreReadmeFile() { var configurationDirectory = "temp-configuration".AsNewDirectoryInfo(); var container = new CompositionContainer(new AssemblyCatalog(this.GetType().Assembly)); File.WriteAllText(Path.Combine(configurationDirectory.FullName, "readme.txt"), "Text"); var configurationCatalog = new LoadConfiguration(configurationDirectory, container); configurationCatalog.Load(); var conf = container.GetExportedValue <SampleConfigurationWithDefaultValues>(); Assert.Equal(5, conf.Value); }
public void RequestingNotFoundConfigurationShouldLoadANewlyCreatedConfiguration() { var container = new CompositionContainer(new AssemblyCatalog(this.GetType().Assembly)); var configurationDirectory = "temp-configuration".AsNewDirectoryInfo(); var configurationCatalog = new LoadConfiguration(configurationDirectory, container); configurationCatalog.Load(); var conf = container.GetExportedValue <SampleConfigurationWithDefaultValues>(); Assert.Equal(5, conf.Value); }
public void RequestingStoredConfigurationWithADefaultTypeAlreadyRegisteredShouldReturnStoredConfiguration() { var configurationDirectory = "temp-configuration".AsNewDirectoryInfo(); var conf = new SampleConfigurationWithDefaultValues() { Value = 10 }; WriteConfiguration <SampleConfigurationWithDefaultValues>(configurationDirectory, conf); var container = new CompositionContainer(new AssemblyCatalog(this.GetType().Assembly)); var configurationCatalog = new LoadConfiguration(configurationDirectory, container); configurationCatalog.Load(); conf = container.GetExportedValue <SampleConfigurationWithDefaultValues>(); Assert.Equal(10, conf.Value); }
protected override void ConfigureContainer(ContainerBuilder builder) { base.ConfigureContainer(builder); var assemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var catalogs = new List <ComposablePartCatalog> { new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x))), new DirectoryCatalog(assemblyDirectory, "Plugins.*.dll"), new DirectoryCatalog(assemblyDirectory, "Plugins.dll"), new AssemblyCatalog(typeof(IItem).Assembly) }; var pluginsPath = Path.Combine(assemblyDirectory, "Plugins"); if (Directory.Exists(pluginsPath)) { catalogs.Add(new DirectoryCatalog(pluginsPath, "Plugins.*.dll")); catalogs.Add(new DirectoryCatalog(pluginsPath, "Plugins.dll")); } else { pluginsPath = assemblyDirectory; } MefContainer = CompositionHost.Initialize(catalogs.ToArray()); var loadConfiguration = new LoadConfiguration(new DirectoryInfo(Path.Combine(assemblyDirectory, "Configuration")), MefContainer); var localConfigurationDirectory = new DirectoryInfo(Path.Combine(assemblyDirectory, "Local.Configuration")); if (localConfigurationDirectory.Exists) { loadConfiguration.AddConfigurationLocation(localConfigurationDirectory); } loadConfiguration.Load(); var dataDirectory = Path.Combine(assemblyDirectory, "Data"); var coreConfiguration = new CoreConfiguration(dataDirectory, pluginsPath); var learningStorageLocation = new DirectoryInfo(Path.Combine(coreConfiguration.DataDirectory, "Learnings")); var indexStorageLocation = new DirectoryInfo(Path.Combine(coreConfiguration.DataDirectory, "Index")); var updateManagerAdapter = new UpdateManagerAdapter(); var scheduler = new StdSchedulerFactory().GetScheduler(); scheduler.JobFactory = new MefJobFactory(new SimpleJobFactory(), MefContainer); var batch = new CompositionBatch(); batch.AddExportedValue(MefContainer); batch.AddExportedValue <ILoadConfiguration>(loadConfiguration); batch.AddExportedValue <ILog>(new NLogAdapterToCoreILog(NLog.LogManager.GetLogger("mef"))); batch.AddExportedValue(coreConfiguration); batch.AddExportedValue(updateManagerAdapter); batch.AddExportedValue <IScheduler>(scheduler); MefContainer.Compose(batch); MefContainer.SatisfyImportsOnce(updateManagerAdapter); builder.RegisterInstance(MefContainer).AsSelf(); builder.RegisterInstance(coreConfiguration).AsSelf(); builder.RegisterInstance(updateManagerAdapter).AsSelf(); builder.RegisterInstance(scheduler).As <IScheduler>(); builder.RegisterInstance <IWindowManager>(new WindowManager()); builder.RegisterInstance <IEventAggregator>(new EventAggregator()); builder.RegisterModule(new LoggingModule(t => new NLogAdapterToCoreILog(NLog.LogManager.GetLogger(t.FullName)), t => NLog.LogManager.GetLogger(t.FullName))); builder.RegisterModule(new SatisfyMefImports(MefContainer)); builder.RegisterType <MainWindowViewModel>().AsSelf(); builder.RegisterType <AutoCompleteBasedOnLucene>().AsSelf(); builder.RegisterType <GetActionsForItem>().As <IGetActionsForItem>(); builder.RegisterType <ConverterRepository>().As <IConverterRepository>(); builder.RegisterType <SourceStorageFactory>().AsSelf().SingleInstance(); builder.RegisterType <FileSystemLearningRepository>().As <ILearningRepository>().WithParameter("input", learningStorageLocation); builder.RegisterType <ScheduleIndexJobs>().As <IStartupTask>(); builder.RegisterType <ScheduleUpdateCheckJob>().As <IStartupTask>(); builder.RegisterType <IronPythonCommandsMefExport>().As <IStartupTask>(); builder.RegisterType <LogScheduledJobs>().As <IStartupTask>(); builder.RegisterType <ProcessMonitor>().As <IStartupTask>(); builder.RegisterType <Shutdown>().AsSelf(); builder.RegisterType <SeparateIndexesDirectoryFactory>() .As <IDirectoryFactory>().WithParameter("root", indexStorageLocation) .SingleInstance(); }