protected override void Arrange() { base.Arrange(); File.Delete(MainConfigurationFile); File.Delete(SatelliteConfigurationSourcePath); var builder = new ConfigurationSourceBuilder(); var configurationSettings = new ConfigurationSourceSection(); configurationSettings.SelectedSource = "System Configuration"; configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath)); configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration")); builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings); builder.ConfigureCaching() .ForCacheManagerNamed("TestCacheManager") .StoreInMemory(); var source = new DesignDictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ConfigurationSource = Container.Resolve<ConfigurationSourceModel>(); ConfigurationSource.Load(source); }
protected override void Arrange() { base.Arrange(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureLogging().LogToCategoryNamed("General").SendTo.EventLog("Listener").SendTo.Msmq("msmqListener"); DesignDictionaryConfigurationSource source = new DesignDictionaryConfigurationSource(); sourceBuilder.UpdateConfigurationWithReplace(source); var applicationModel = Container.Resolve <ApplicationViewModel>(); var sourceModel = applicationModel.CurrentConfigurationSource; sourceModel.Load(source); foreach (var element in sourceModel.Sections.SelectMany(x => x.DescendentElements())) { element.InheritedFromParentConfiguration = false; } applicationModel.NewEnvironment(); Environment = applicationModel.Environments.First(); LoggingSectionViewModel = sourceModel.Sections.Where(x => x.SectionName == LoggingSettings.SectionName).First(); }
public void EntLib5UseCase() { // construct the Configuration Source to use var builder = new ConfigurationSourceBuilder(); // fluent API configuration builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("Simple") .SendTo.FlatFile("Simple Log File") .FormatWith(new FormatterBuilder() .TextFormatterNamed("simpleFormat") .UsingTemplate("{timestamp} : {message}{newline}")) .ToFile("simple.log"); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); ILog log = LogManager.GetLogger(GetType()); log.Debug("Debug Event Log Entry."); log.Warn("Warning Event Log Entry."); }
public void EntLib5FactoryTestWithFluentConfig() { // construct the Configuration Source to use var builder = new ConfigurationSourceBuilder(); // fluent API configuration builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("Simple") .SendTo.FlatFile("Simple Log File") .FormatWith(new FormatterBuilder() .TextFormatterNamed("simpleFormat") .UsingTemplate("{timestamp} : {message}{newline}")) .ToFile("simple.log"); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); // initialize the EntLib5 Logger factory with configuration file EntLib5Factory factory = new EntLib5Factory(); ILog log = factory.GetLogger(GetType()); Assert.IsNotNull(log); Assert.IsNotNull(log as EntLib5Logger); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .LogToCategoryNamed("General") .SendTo.EventLog("Event Log Listener") .FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter")) .ToLog("Application"); builder.ConfigureExceptionHandling() .GivenPolicyWithName("AllExceptions") .ForExceptionType <Exception>() .LogToCategory("General") .ThenDoNothing() .GivenPolicyWithName("OtherExceptions") .ForExceptionType <ArgumentNullException>() .LogToCategory("InvalidCategoryName") .ThenDoNothing(); var configuration = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configuration); LoggingSection = GetSection(LoggingSettings.SectionName, configuration); ExceptionHandlingSection = GetSection(ExceptionHandlingSettings.SectionName, configuration); }
protected override void Arrange() { base.Arrange(); File.Delete(MainConfigurationFile); File.Delete(SatelliteConfigurationSourcePath); var builder = new ConfigurationSourceBuilder(); var configurationSettings = new ConfigurationSourceSection(); configurationSettings.SelectedSource = "System Configuration"; configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath)); configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration")); builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings); builder.ConfigureExceptionHandling() .GivenPolicyWithName("policy") .ForExceptionType <Exception>(); var source = new DesignDictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ConfigurationSource = Container.Resolve <ConfigurationSourceModel>(); ConfigurationSource.Load(source); }
protected override void Arrange() { base.Arrange(); validator = new LogFormatterValidator(); errors = new List<ValidationResult>(); IConfigurationSource source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuiler = new ConfigurationSourceBuilder(); sourceBuiler.ConfigureExceptionHandling() .GivenPolicyWithName("policy") .ForExceptionType<Exception>() .LogToCategory("category") .UsingExceptionFormatter<BadImageFormatException>(); sourceBuiler.UpdateConfigurationWithReplace(source); ExceptionHandlingSettings EhabSettings = (ExceptionHandlingSettings)source.GetSection(ExceptionHandlingSettings.SectionName); var sectionModel = SectionViewModel.CreateSection(Container, "Ehab Section", EhabSettings); properties = sectionModel.GetDescendentsOfType<LoggingExceptionHandlerData>().First().Properties; }
protected override void Arrange() { base.Arrange(); File.Delete(MainConfigurationFile); File.Delete(SatelliteConfigurationSourcePath); var builder = new ConfigurationSourceBuilder(); var configurationSettings = new ConfigurationSourceSection(); configurationSettings.SelectedSource = "System Configuration"; configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath)); configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration")); builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings); builder.ConfigureCaching() .ForCacheManagerNamed("TestCacheManager") .StoreInMemory(); var source = new DesignDictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ConfigurationSource = Container.Resolve <ConfigurationSourceModel>(); ConfigurationSource.Load(source); }
/// <summary> /// Define the logging parameters /// </summary> public static void DefineLogger() { var builder = new ConfigurationSourceBuilder(); string loggerPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("LogWriter") .WithOptions.SetAsDefaultCategory() .SendTo.RollingFile("Rolling Flat File Trace Listener") .RollAfterSize(1000) .FormatWith(new FormatterBuilder() .TextFormatterNamed("Text Formatter") .UsingTemplate(@"Timestamp: {timestamp}{newline}Message: {message},{newline}Category: {category},{newline}Severity: {severity},{newline}Title:{title},{newline}ProcessId: {localProcessId},{newline}Process Name: {localProcessName},{newline}Thread Name: {threadName}")) .ToFile(loggerPath + Properties.Settings.Default.LogFileFolder); // Reference app.config using (DictionaryConfigurationSource configSource = new DictionaryConfigurationSource()) { builder.UpdateConfigurationWithReplace(configSource); LogWriterFactory logWriterFactory = new LogWriterFactory(configSource); LogWriter logWriter = logWriterFactory.Create(); Logger.SetLogWriter(new LogWriterFactory(configSource).Create()); } }
protected override void Arrange() { base.Arrange(); Builder = new ConfigurationSourceBuilder(); DataConfig = Builder.ConfigureData(); }
/// <summary> /// Initializes a new instance of the <see cref="EntLib5Factory"/> class. /// </summary> /// <param name="EntLib5ConfigurationSrc">The enterprise library 5.0 configuration source to load. Supercedes any configuration found in the Config file.</param> public EntLib5Factory(IConfigurationSource EntLib5ConfigurationSrc) { // replace any settings from App.Config with the ones in the provided config source var builder = new ConfigurationSourceBuilder(); builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc); }
private void ConfigureExceptionHandling() { var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); builder .ConfigureExceptionHandling() .GivenPolicyWithName(DefaultPolicy) .ForExceptionType<DeleteConstraintException>() .HandleCustom<HttpErrorExceptionHandler>() .ThenThrowNewException() .ForExceptionType<BusinessValidationException>() .HandleCustom<BusinessValidationExceptionHandler>() .ThenThrowNewException() .ForExceptionType<BusinessException>() .HandleCustom<HttpErrorExceptionHandler>() .ThenThrowNewException() .ForExceptionType<Exception>() .LogToCategory("General") .WithSeverity(TraceEventType.Critical) .UsingExceptionFormatter<TextExceptionFormatter>() .HandleCustom( typeof(HttpErrorExceptionHandler), new NameValueCollection { { HttpErrorExceptionHandler.StatusCodeKey, HttpStatusCode.InternalServerError.ToString("G") }, { HttpErrorExceptionHandler.MessageKey, "An error has occurred while consuming this service. Please contact your administrator for more information." }, { HttpErrorExceptionHandler.AppendHandlingIdKey, bool.TrueString } }) .ThenThrowNewException(); builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); }
protected override void Arrange() { base.Arrange(); Source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureExceptionHandling() .GivenPolicyWithName("SomePolicy") .ForExceptionType <Exception>() .ReplaceWith <ApplicationException>() .WrapWith <ArgumentException>() .ThenThrowNewException() .ForExceptionType <ArithmeticException>() .LogToCategory("ArithmicExceptions") .ThenDoNothing() .GivenPolicyWithName("Global Policy") .ForExceptionType <Exception>() .ReplaceWith <ApplicationException>() .UsingMessage("replacement message") .WrapWith <Exception>() .ThenNotifyRethrow() .ForExceptionType <InvalidCastException>() .WrapWith <ApplicationException>() .WrapWith <Exception>() .UsingMessage("yes, thats a known bug") .ThenThrowNewException(); sourceBuilder.UpdateConfigurationWithReplace(Source); Section = (ExceptionHandlingSettings)Source.GetSection(ExceptionHandlingSettings.SectionName); }
protected override void Arrange() { base.Arrange(); IConfigurationSource source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuiler = new ConfigurationSourceBuilder(); sourceBuiler.ConfigureLogging() .WithOptions.DisableTracing() .DoNotRevertImpersonation() .FilterOnPriority("prio filter").StartingWithPriority(10) .FilterOnCategory("categoryFiler").AllowAllCategoriesExcept("cat1") .LogToCategoryNamed("General") .SendTo.EventLog("Event Log Listener") .FormatWith(new FormatterBuilder().TextFormatterNamed("Default")) .LogToCategoryNamed("Critical") .SendTo.SharedListenerNamed("Event Log Listener") .SendTo.Custom <MyCustomListener>("Custom Listener") .SendTo.Email("Email Listener") .SendTo.SystemDiagnosticsListener("system diagnostics") .LogToCategoryNamed("msmq") .SendTo.Msmq("msmq"); sourceBuiler.UpdateConfigurationWithReplace(source); LoggingSection = (LoggingSettings)source.GetSection(LoggingSettings.SectionName); }
/// <summary> /// ConfigurationSourceBuilderの内容を元にIServiceProviderを作成します。 /// </summary> /// <param name="self"></param> /// <returns></returns> public static IServiceLocator CreateContainer(this ConfigurationSourceBuilder self) { var configuration = new DictionaryConfigurationSource(); self.UpdateConfigurationWithReplace(configuration); return(EnterpriseLibraryContainer.CreateDefaultContainer(configuration)); }
private void ConfigureExceptionHandling() { var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); builder .ConfigureExceptionHandling() .GivenPolicyWithName(ValidationPolicy) .ForExceptionType <DeleteConstraintException>() .HandleCustom <BusinessValidationHandler>() .ThenThrowNewException() .ForExceptionType <BusinessValidationException>() .ThenNotifyRethrow() .ForExceptionType <BusinessException>() .HandleCustom <BusinessValidationHandler>() .ThenThrowNewException() .GivenPolicyWithName(DefaultPolicy) .ForExceptionType <Exception>() .LogToCategory("General") .WithSeverity(TraceEventType.Critical) .UsingExceptionFormatter <TextExceptionFormatter>() .WrapWith <Exception>() .UsingMessage("An error has occurred while processing request. Please contact your administrator for more information. [Error ID: {handlingInstanceID}]") .ThenThrowNewException(); builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); }
protected override void Arrange() { base.Arrange(); source = new DesignDictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureData().ForDatabaseNamed("connection-string1").ThatIs.ASqlDatabase().WithConnectionString("connectionStringValueXYZ").AsDefault() .ForDatabaseNamed("connection-string2").ThatIs.AnOracleDatabase().WithConnectionString("OracleConnectionString").WithPackageNamed("x").AndPrefix("XYZ") .ForDatabaseNamed("connection-string3").ThatIs.AnOracleDatabase().WithConnectionString("OracleConnectionString").WithPackageNamed("x").AndPrefix("XYZ"); sourceBuilder.UpdateConfigurationWithReplace(source); DatabaseSettings dbSettings = (DatabaseSettings)source.GetSection(DatabaseSettings.SectionName); dbSettings.ProviderMappings.Add(new DbProviderMapping("dbpro1", "dbtype")); dbSettings.ProviderMappings.Add(new DbProviderMapping("dbpro2", "dbtype")); source.Remove(DatabaseSettings.SectionName); source.Add(DatabaseSettings.SectionName, dbSettings); var configurationSection = source.GetSection(DataAccessDesignTime.ConnectionStringSettingsSectionName); var configurationSourceModel = Container.Resolve <ConfigurationSourceModel>(); configurationSourceModel.Load(source); databaseSectionViewModel = configurationSourceModel.Sections .Where(x => x.SectionName == DataAccessDesignTime.ConnectionStringSettingsSectionName) .Single(); }
protected override void Arrange() { base.Arrange(); source = new DesignDictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureData().ForDatabaseNamed("connection-string1").ThatIs.ASqlDatabase().WithConnectionString("connectionStringValueXYZ").AsDefault() .ForDatabaseNamed("connection-string2").ThatIs.AnOracleDatabase().WithConnectionString("OracleConnectionString").WithPackageNamed("x").AndPrefix("XYZ") .ForDatabaseNamed("connection-string3").ThatIs.AnOracleDatabase().WithConnectionString("OracleConnectionString").WithPackageNamed("x").AndPrefix("XYZ"); sourceBuilder.UpdateConfigurationWithReplace(source); DatabaseSettings dbSettings = (DatabaseSettings)source.GetSection(DatabaseSettings.SectionName); dbSettings.ProviderMappings.Add(new DbProviderMapping("dbpro1", "dbtype")); dbSettings.ProviderMappings.Add(new DbProviderMapping("dbpro2", "dbtype")); source.Remove(DatabaseSettings.SectionName); source.Add(DatabaseSettings.SectionName, dbSettings); var configurationSection = source.GetSection(DataAccessDesignTime.ConnectionStringSettingsSectionName); var configurationSourceModel = Container.Resolve<ConfigurationSourceModel>(); configurationSourceModel.Load(source); databaseSectionViewModel = configurationSourceModel.Sections .Where(x => x.SectionName == DataAccessDesignTime.ConnectionStringSettingsSectionName) .Single(); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .LogToCategoryNamed("category") .SendTo .EventLog("listener") .SpecialSources .AllEventsCategory .SendTo .EventLog("listener") .SpecialSources .LoggingErrorsAndWarningsCategory .SendTo .EventLog("listener") .SpecialSources .UnprocessedCategory .SendTo .EventLog("listener"); var source = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ElementLookup = Container.Resolve<ElementLookup>(); LoggingSection = (LoggingSettings)source.GetSection(LoggingSettings.SectionName); }
protected override void Arrange() { base.Arrange(); File.Delete(MainConfigurationFile); File.Delete(SatelliteConfigurationSourcePath); var builder = new ConfigurationSourceBuilder(); var configurationSettings = new ConfigurationSourceSection(); configurationSettings.SelectedSource = "System Configuration"; configurationSettings.Sources.Add(new FileConfigurationSourceElement(SatelliteSourceName, SatelliteConfigurationSourcePath)); configurationSettings.Sources.Add(new SystemConfigurationSourceElement("System Configuration")); builder.AddSection(ConfigurationSourceSection.SectionName, configurationSettings); builder.ConfigureExceptionHandling() .GivenPolicyWithName("policy") .ForExceptionType<Exception>(); var source = new DesignDictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ConfigurationSource = Container.Resolve<ConfigurationSourceModel>(); ConfigurationSource.Load(source); }
private void configureEntLib() { var formatterStandard = new FormatterBuilder().TextFormatterNamed("Text Formatter").UsingTemplate( "Timestamp: {timestamp}{newline}Message: {message}{newline}Severity: {severity}{newline}Machine: {machine}{newline}Process Name: {processName}{newline}Extended Properties: {dictionary({key} - {value}{newline})}"); var conf = new ConfigurationSourceBuilder(); var logConfig = conf.ConfigureLogging(); logConfig.WithOptions.LogToCategoryNamed("Exception").SendTo.RollingFile( "ExceptionFileListener").WithHeader("----------------------------------------").WithFooter("----------------------------------------").ToFile(UserContext.Settings.ExceptionsLogFile); logConfig.WithOptions.LogToCategoryNamed("General").SendTo.RollingFile( "FlatFile TraceListener").WithHeader("----------------------------------------").WithFooter("----------------------------------------").FormatWith(formatterStandard).ToFile(UserContext.Settings.StandardLogFile); logConfig.WithOptions.LogToCategoryNamed("email").SendTo.Email("email").FormatWith(formatterStandard).UsingSmtpServer( ApplicationSettings.MailSmtp).WithUserNameAndPassword(ApplicationSettings.MailUserName, ApplicationSettings.MailPassword).To( ApplicationSettings.MailAccount).From( ApplicationSettings.MailAccount).UseSSL(true); //configure cache var cacheCfg = conf.ConfigureCaching(); cacheCfg.ForCacheManagerNamed(PicturesCache.PicturesCacheName).StoreInIsolatedStorage( "Isolated Storage Cache Store").UsePartition("PicturesCache1"); cacheCfg.ForCacheManagerNamed("ErrorCache").StoreInMemory(); var configSource = new DictionaryConfigurationSource(); conf.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); BodyArchitect.Logger.Log.EnableExceptionLog = Settings1.Default.LogErrorEnabled; BodyArchitect.Logger.Log.EnableStandardLog = Settings1.Default.LogStandardEnabled; }
public void EntLib5FactoryTestWithFluentConfig() { // construct the Configuration Source to use var builder = new ConfigurationSourceBuilder(); // fluent API configuration builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("Simple") .SendTo.FlatFile("Simple Log File") .FormatWith(new FormatterBuilder() .TextFormatterNamed("simpleFormat") .UsingTemplate("{timestamp} : {message}{newline}")) .ToFile("simple.log"); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); // initialize the EntLib5 Logger factory with configuration file EntLib5Factory factory = new EntLib5Factory(); ILog log = factory.GetLogger(GetType()); Assert.IsNotNull(log); Assert.IsNotNull(log as EntLib5Logger); }
private void ConfigureLogging() { var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); const string DefaultListenerName = "Default"; builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .SpecialSources .LoggingErrorsAndWarningsCategory .SendTo.SharedListenerNamed(DefaultListenerName) .SpecialSources .UnprocessedCategory .SendTo.SharedListenerNamed(DefaultListenerName) .SpecialSources .AllEventsCategory .SendTo.SharedListenerNamed(DefaultListenerName) .LogToCategoryNamed("General") .WithOptions.SetAsDefaultCategory() .SendTo.SharedListenerNamed(DefaultListenerName); builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); this.Container.RegisterType <TraceListener, CommonLoggingEntlibTraceListener>( DefaultListenerName, new ContainerControlledLifetimeManager(), new InjectionFactory(this.CreateListener)); }
protected override void Arrange() { base.Arrange(); IConfigurationSource source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuiler = new ConfigurationSourceBuilder(); sourceBuiler.ConfigureLogging() .WithOptions.DisableTracing() .DoNotRevertImpersonation() .FilterOnPriority("prio filter").StartingWithPriority(10) .FilterOnCategory("categoryFiler").AllowAllCategoriesExcept("cat1") .LogToCategoryNamed("General") .SendTo.EventLog("Event Log Listener") .FormatWith(new FormatterBuilder().TextFormatterNamed("Default")) .LogToCategoryNamed("Critical") .SendTo.SharedListenerNamed("Event Log Listener") .SendTo.Custom<MyCustomListener>("Custom Listener") .SendTo.Email("Email Listener") .SendTo.SystemDiagnosticsListener("system diagnostics") .LogToCategoryNamed("msmq") .SendTo.Msmq("msmq"); sourceBuiler.UpdateConfigurationWithReplace(source); LoggingSection = (LoggingSettings)source.GetSection(LoggingSettings.SectionName); }
protected override void Arrange() { base.Arrange(); Source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureExceptionHandling() .GivenPolicyWithName("SomePolicy") .ForExceptionType<Exception>() .ReplaceWith<ApplicationException>() .WrapWith<ArgumentException>() .ThenThrowNewException() .ForExceptionType<ArithmeticException>() .LogToCategory("ArithmicExceptions") .ThenDoNothing() .GivenPolicyWithName("Global Policy") .ForExceptionType<Exception>() .ReplaceWith<ApplicationException>() .UsingMessage("replacement message") .WrapWith<Exception>() .ThenNotifyRethrow() .ForExceptionType<InvalidCastException>() .WrapWith<ApplicationException>() .WrapWith<Exception>() .UsingMessage("yes, thats a known bug") .ThenThrowNewException(); sourceBuilder.UpdateConfigurationWithReplace(Source); Section = (ExceptionHandlingSettings)Source.GetSection(ExceptionHandlingSettings.SectionName); }
protected override void Arrange() { base.Arrange(); validator = new LogFormatterValidator(); errors = new List <ValidationResult>(); IConfigurationSource source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuiler = new ConfigurationSourceBuilder(); sourceBuiler.ConfigureExceptionHandling() .GivenPolicyWithName("policy") .ForExceptionType <Exception>() .LogToCategory("category") .UsingExceptionFormatter <BadImageFormatException>(); sourceBuiler.UpdateConfigurationWithReplace(source); ExceptionHandlingSettings EhabSettings = (ExceptionHandlingSettings)source.GetSection(ExceptionHandlingSettings.SectionName); var sectionModel = SectionViewModel.CreateSection(Container, "Ehab Section", EhabSettings); properties = sectionModel.GetDescendentsOfType <LoggingExceptionHandlerData>().First().Properties; }
protected override void Arrange() { base.Arrange(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder .ConfigureLogging() .WithOptions .FilterCustom<MockLogFilter>("filter") .LogToCategoryNamed("General") .SendTo .SystemDiagnosticsListener("listener") .SendTo .Msmq("msmqlistener") .LogToCategoryNamed("Other") .SendTo .EventLog("eventlog"); ; DesignDictionaryConfigurationSource source = new DesignDictionaryConfigurationSource(); sourceBuilder.UpdateConfigurationWithReplace(source); var sourceModel = Container.Resolve<ConfigurationSourceModel>(); sourceModel.Load(source); LoggingSectionViewModel = sourceModel.Sections.Where(x => x.SectionName == LoggingSettings.SectionName).First(); }
public void EntLib5UseCase() { // construct the Configuration Source to use var builder = new ConfigurationSourceBuilder(); // fluent API configuration builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("Simple") .SendTo.FlatFile("Simple Log File") .FormatWith(new FormatterBuilder() .TextFormatterNamed("simpleFormat") .UsingTemplate("{timestamp} : {message}{newline}")) .ToFile("simple.log"); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); ILog log = LogManager.GetLogger(GetType()); log.Debug("Debug Event Log Entry."); log.Warn("Warning Event Log Entry."); }
protected override void Arrange() { base.Arrange(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder .ConfigureLogging() .WithOptions .FilterCustom <MockLogFilter>("filter") .LogToCategoryNamed("General") .SendTo .SystemDiagnosticsListener("listener") .SendTo .Msmq("msmqlistener") .LogToCategoryNamed("Other") .SendTo .EventLog("eventlog");; DesignDictionaryConfigurationSource source = new DesignDictionaryConfigurationSource(); sourceBuilder.UpdateConfigurationWithReplace(source); var sourceModel = Container.Resolve <ConfigurationSourceModel>(); sourceModel.Load(source); LoggingSectionViewModel = sourceModel.Sections.Where(x => x.SectionName == LoggingSettings.SectionName).First(); }
static void Main(string[] args) { // 構成情報を組み立てる var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .SpecialSources .AllEventsCategory .SendTo .FlatFile("FlatFileListener") .FormatWith( new FormatterBuilder() .TextFormatterNamed("TextFormatter") .UsingTemplate("{timestamp(local:yyyy/MM/dd HH:mm:ss.fff)}: {message}")) .ToFile("output.txt"); // 組み立てた構成情報からIServiceLocatorを作成 EnterpriseLibraryContainer.Current = builder.CreateContainer(); // EnterpriseLibraryのコンテナからLogging Application BlockのLog書き込み部品を取得 var logger = EnterpriseLibraryContainer.Current.GetInstance <LogWriter>(); // ログに出力する logger.Write("Hello world"); // ログを表示 Process.Start("output.txt"); }
static void Main(string[] args) { // 構成情報を組み立てる var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .SpecialSources .AllEventsCategory .SendTo .FlatFile("FlatFileListener") .FormatWith( new FormatterBuilder() .TextFormatterNamed("TextFormatter") .UsingTemplate("{timestamp(local:yyyy/MM/dd HH:mm:ss.fff)}: {message}")) .ToFile("output.txt"); // 組み立てた構成情報からConfigurationSourceを作成 var config = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(config); // 構成情報を元にEnterpriseLibraryのコンテナの初期化 EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(config); // EnterpriseLibraryのコンテナからLogging Application BlockのLog書き込み部品を取得 var logger = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>(); // ログに出力する logger.Write("Hello world"); // ログを表示 Process.Start("output.txt"); }
private void ConfigureLogging() { var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); const string DefaultListenerName = "Default"; builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .SpecialSources .LoggingErrorsAndWarningsCategory .SendTo.SharedListenerNamed(DefaultListenerName) .SpecialSources .UnprocessedCategory .SendTo.SharedListenerNamed(DefaultListenerName) .SpecialSources .AllEventsCategory .SendTo.SharedListenerNamed(DefaultListenerName) .LogToCategoryNamed("General") .WithOptions.SetAsDefaultCategory() .SendTo.SharedListenerNamed(DefaultListenerName); builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); this.Container.RegisterType<TraceListener, CommonLoggingEntlibTraceListener>( DefaultListenerName, new ContainerControlledLifetimeManager(), new InjectionFactory(this.CreateListener)); }
private void ConfigureExceptionHandling() { var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); builder .ConfigureExceptionHandling() .GivenPolicyWithName(ValidationPolicy) .ForExceptionType<DeleteConstraintException>() .HandleCustom<BusinessValidationHandler>() .ThenThrowNewException() .ForExceptionType<BusinessValidationException>() .ThenNotifyRethrow() .ForExceptionType<BusinessException>() .HandleCustom<BusinessValidationHandler>() .ThenThrowNewException() .GivenPolicyWithName(DefaultPolicy) .ForExceptionType<Exception>() .LogToCategory("General") .WithSeverity(TraceEventType.Critical) .UsingExceptionFormatter<TextExceptionFormatter>() .WrapWith<Exception>() .UsingMessage("An error has occurred while processing request. Please contact your administrator for more information. [Error ID: {handlingInstanceID}]") .ThenThrowNewException(); builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .LogToCategoryNamed("category") .SendTo .EventLog("listener") .SpecialSources .AllEventsCategory .SendTo .EventLog("listener") .SpecialSources .LoggingErrorsAndWarningsCategory .SendTo .EventLog("listener") .SpecialSources .UnprocessedCategory .SendTo .EventLog("listener"); var source = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ElementLookup = Container.Resolve <ElementLookup>(); LoggingSection = (LoggingSettings)source.GetSection(LoggingSettings.SectionName); }
public override void createTestFixture() { base.createTestFixture(); ObjectsConverter.Configure(); configureLogging(); clientInformation = new ClientInformation() { Version = Const.ServiceVersion }; clientInformation.ApplicationLanguage = "en"; clientInformation.PlatformVersion = "fgfdgdfg"; clientInformation.ApplicationVersion = "1.0.0.0"; var conf = new ConfigurationSourceBuilder(); conf.ConfigureCaching().ForCacheManagerNamed(SecurityManager.AuthenticationCacheName).StoreInMemory(); var configSource = new DictionaryConfigurationSource(); conf.UpdateConfigurationWithReplace(configSource); var xmlStream = DateTimeExtension.GetResource("BodyArchitect.UnitTests.V2.BAPointsTests.BAPoints.xml"); var paymentsManager = new PaymentsManager(); this.paymentsManager = paymentsManager.Load(xmlStream); InternalBodyArchitectService.PaymentsManager = this.paymentsManager; EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .LogToCategoryNamed("General") .SendTo.EventLog("Event Log Listener") .FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter")) .ToLog("Application"); builder.ConfigureExceptionHandling() .GivenPolicyWithName("AllExceptions") .ForExceptionType<Exception>() .LogToCategory("General") .ThenDoNothing() .GivenPolicyWithName("OtherExceptions") .ForExceptionType<ArgumentNullException>() .LogToCategory("InvalidCategoryName") .ThenDoNothing(); var configuration = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configuration); LoggingSection = GetSection(LoggingSettings.SectionName, configuration); ExceptionHandlingSection = GetSection(ExceptionHandlingSettings.SectionName, configuration); }
static void LogWithFluentInterface(CustomLogEntry logEntry) { var builder = new ConfigurationSourceBuilder(); builder.ConfigureData() .ForDatabaseNamed("Logging") .ThatIs.ASqlDatabase() .WithConnectionString(@"data source=.\SQLEXPRESS;Integrated Security=SSPI;Database=Logging") .AsDefault(); builder.ConfigureLogging() .WithOptions .DoNotRevertImpersonation() .LogToCategoryNamed("General") .WithOptions.SetAsDefaultCategory() .SendTo.CustomDatabase("Custom Database Trace Listener") .WithAddCategoryStoredProcedure("AddCategory") .UseDatabase("Logging") .Filter(System.Diagnostics.SourceLevels.All) .WithWriteLogStoredProcedure("WriteLog") .FormatWithSharedFormatter("Text Formatter") .SpecialSources.LoggingErrorsAndWarningsCategory .SendTo.EventLog("Event Log Listener") .FormatWith(new FormatterBuilder() .TextFormatterNamed("Text Formatter") .UsingTemplate(@"Timestamp: {timestamp}{newline} Message: {message}{newline} Category: {category}{newline} Priority: {priority}{newline} EventId: {eventid}{newline} Severity: {severity}{newline} Title:{title}{newline} Machine: {localMachine}{newline} App Domain: {localAppDomain}{newline} ProcessId: {localProcessId}{newline} Process Name: {localProcessName}{newline} Thread Name: {threadName}{newline} Win32 ThreadId:{win32ThreadId}{newline} Extended Properties: {dictionary({key} - {value}{newline})}")) .ToLog("Application") .ToMachine(".") .UsingEventLogSource("Enterprise Library Logging") .Filter(SourceLevels.All) ; var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); var dbProviderFactory = new DatabaseProviderFactory(configSource); DatabaseFactory.SetDatabaseProviderFactory(dbProviderFactory, false); var logWriterFactory = new LogWriterFactory(configSource); var logWriter = logWriterFactory.Create(); logWriter.Write(logEntry); // Re-initialize static Logger Logger.SetLogWriter(logWriter, false); Logger.Write("Test2", "General"); }
public void BuildsWcfExceptionShildingWithFluentConfiguration() { DictionaryConfigurationSource emptyConfigSource = new DictionaryConfigurationSource(); ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder(); builder.ConfigureExceptionHandling() .GivenPolicyWithName("policy") .ForExceptionType(typeof(NotFiniteNumberException)) .ShieldExceptionForWcf(typeof(MockFaultContract), "fault message") .MapProperty("Message", "{Message}") .MapProperty("Data", "{Data}") .MapProperty("SomeNumber", "{OffendingNumber}") .ThenThrowNewException(); builder.UpdateConfigurationWithReplace(emptyConfigSource); ExceptionHandlingSettings settings = emptyConfigSource.GetSection(ExceptionHandlingSettings.SectionName) as ExceptionHandlingSettings; Assert.IsNotNull(settings); Assert.AreEqual(1, settings.ExceptionPolicies.Count); var policy = settings.ExceptionPolicies.Get("policy"); Assert.IsNotNull(policy); Assert.AreEqual(1, policy.ExceptionTypes.Count); var configuredException = policy.ExceptionTypes.Get(0); Assert.AreEqual(typeof(NotFiniteNumberException), configuredException.Type); Assert.AreEqual(PostHandlingAction.ThrowNewException, configuredException.PostHandlingAction); Assert.AreEqual(1, configuredException.ExceptionHandlers.Count); var handler = configuredException.ExceptionHandlers.Get(0) as FaultContractExceptionHandlerData; Assert.IsNotNull(handler); Assert.AreEqual(typeof(MockFaultContract).AssemblyQualifiedName, handler.FaultContractType); Assert.AreEqual("fault message", handler.ExceptionMessage); Assert.AreEqual(3, handler.PropertyMappings.Count); Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "Message" && p.Source == "{Message}")); Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "Data" && p.Source == "{Data}")); Assert.IsNotNull(handler.PropertyMappings.SingleOrDefault(p => p.Name == "SomeNumber" && p.Source == "{OffendingNumber}")); var exceptionManager = settings.BuildExceptionManager(); NotFiniteNumberException originalException = new NotFiniteNumberException("MyException", 555); originalException.Data.Add("someKey", "someValue"); try { exceptionManager.HandleException(originalException, "policy"); Assert.Fail("Should have thrown"); } catch (FaultContractWrapperException ex) { MockFaultContract fault = (MockFaultContract)ex.FaultContract; Assert.AreEqual(originalException.Message, fault.Message); Assert.AreEqual(originalException.Data.Count, fault.Data.Count); Assert.AreEqual(originalException.Data["someKey"], fault.Data["someKey"]); Assert.AreEqual(originalException.OffendingNumber, fault.SomeNumber); } }
public void Then_ConfigurationSourceContainsLoggingSettings() { var configurationSource = new DictionaryConfigurationSource(); ConfigurationSourceBuilder.UpdateConfigurationWithReplace(configurationSource); Assert.IsNotNull(configurationSource.GetSection(LoggingSettings.SectionName)); }
protected override void Arrange() { ConfigurationSourceBuilder = new ConfigurationSourceBuilder(); CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching(); ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName); }
protected override void Arrange() { ConfigurationSourceBuilder = new ConfigurationSourceBuilder(); CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching(); ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName); }
/// <summary> /// Initializes a new instance of the <see cref="EntLib5Factory"/> class. /// </summary> /// <param name="EntLib5ConfigurationSrc">The enterprise library 5.0 configuration source to load. Supercedes any configuration found in the Config file.</param> public EntLib5Factory(IConfigurationSource EntLib5ConfigurationSrc) { // replace any settings from App.Config with the ones in the provided config source var builder = new ConfigurationSourceBuilder(); builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc); }
protected override void Arrange() { configurationSourceBuilder = new ConfigurationSourceBuilder(); policy = configurationSourceBuilder .ConfigureExceptionHandling() .GivenPolicyWithName(policyName); exception = policy.ForExceptionType(exceptionType); }
public void ThrowsArgumentExceptionWhenPolicyNameIsEmpty() { ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder(); ExceptionAssertHelper.Throws <ArgumentException>(() => builder.ConfigureExceptionHandling() .GivenPolicyWithName(string.Empty) .ForExceptionType <Exception>().ThenDoNothing()); }
protected override void Arrange() { configurationSourceBuilder = new ConfigurationSourceBuilder(); policy = configurationSourceBuilder .ConfigureExceptionHandling() .GivenPolicyWithName(policyName); exception = policy.ForExceptionType(exceptionType); }
protected override void Arrange() { ConfigurationSourceBuilder = new ConfigurationSourceBuilder(); CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching(); ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName); EncryptUsing = ConfigureCacheManager.StoreInIsolatedStorage(cacheManagerStoreName).EncryptUsing; }
protected override void Arrange() { ConfigurationSourceBuilder = new ConfigurationSourceBuilder(); CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching(); ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName); EncryptUsing = ConfigureCacheManager.StoreInIsolatedStorage(cacheManagerStoreName).EncryptUsing; }
//as long as this compiles we should be good public void Then_CanComposeFluentInterfaces() { ConfigurationSourceBuilder.ConfigureCaching() .ForCacheManagerNamed("cache manager") .UseAsDefaultCache() .StoreInIsolatedStorage("store") .EncryptUsing.SharedEncryptionProviderNamed("shared encryption provider") .ForCustomCacheManagerNamed("another provider", typeof(CustomCacheManager)) .UseAsDefaultCache(); }
public static void LoadConfigurationForCaching() { var builder = new ConfigurationSourceBuilder(); builder.ConfigureCaching() .ForCacheManagerNamed("MyCache") .WithOptions .UseAsDefaultCache().StoreInMemory(); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
/// <summary> /// Initializes a new instance of the <see cref="EntLib5Factory"/> class. /// </summary> /// <param name="EntLib5ConfigurationFile">The enterprise library 5.0 configuration file to load and watch. Supercedes any configuration found in the Config file.</param> public EntLib5Factory(string EntLib5ConfigurationFile) { // verify provided file exists var fi = new System.IO.FileInfo(EntLib5ConfigurationFile); if (fi.Exists) { var builder = new ConfigurationSourceBuilder(); var EntLib5ConfigurationSrc = new FileConfigurationSource(EntLib5ConfigurationFile, true); builder.UpdateConfigurationWithReplace(EntLib5ConfigurationSrc); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(EntLib5ConfigurationSrc); } }
public static void LoadConfigurationForCaching() { var builder = new ConfigurationSourceBuilder(); builder.ConfigureCaching() .ForCacheManagerNamed("MyCache") .WithOptions .UseAsDefaultCache().StoreInMemory(); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
public void BuildsEmptyExceptionHandlingSettings() { DictionaryConfigurationSource emptyConfigSource = new DictionaryConfigurationSource(); ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder(); builder.ConfigureExceptionHandling(); builder.UpdateConfigurationWithReplace(emptyConfigSource); var settings = emptyConfigSource.GetSection(ExceptionHandlingSettings.SectionName) as ExceptionHandlingSettings; Assert.IsNotNull(settings); Assert.AreEqual(0, settings.ExceptionPolicies.Count); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureData() .ForDatabaseNamed("someDatabase") .AsDefault(); var source = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); ElementLookup = Container.Resolve<ElementLookup>(); DatabaseSection = (DatabaseSettings)source.GetSection(DatabaseSettings.SectionName); }
protected override void Arrange() { base.Arrange(); var sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureLogging() .LogToCategoryNamed("General") .SendTo.EventLog("eventlog listener") .ToLog("Application") .LogToCategoryNamed("ArithmicExceptions") .SendTo.SharedListenerNamed("eventlog listener"); sourceBuilder.UpdateConfigurationWithReplace(Source); LogginSettings = (LoggingSettings)Source.GetSection(LoggingSettings.SectionName); }
protected override void Initialize() { this.WellKnownITypeNameAutoRegistration<ContainerControlledLifetimeManager>(WellKnownAppParts.Manager); this.Container.RegisterType<IApplicationPrincipal, ThreadApplicationPrincipal>(new ContainerControlledLifetimeManager()); var configurationSource = new DictionaryConfigurationSource(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureCryptography() .EncryptUsingHashAlgorithmProviderNamed(UserManager.HashInstance) .WithOptions .UsingHashAlgorithm<Zetetic.Security.Pbkdf2Hash>() /*.SetAsDefault()*/; // do not want Pbkdf2Hash (low speed algorithm) to be default builder.UpdateConfigurationWithReplace(configurationSource); var configurator = new UnityContainerConfigurator(this.Container); EnterpriseLibraryContainer.ConfigureContainer(configurator, configurationSource); }
static Log() { var builder = new ConfigurationSourceBuilder(); builder.ConfigureLogging() .LogToCategoryNamed("General") .WithOptions.SetAsDefaultCategory() .SendTo.FlatFile("Log File") .FormatWith(new FormatterBuilder() .TextFormatterNamed("Text Formatter") .UsingTemplate("{message}{newline}")) .ToFile("AppLog.txt"); var configSource = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
protected override void Arrange() { base.Arrange(); ConfigurationSourceBuilder builder = new ConfigurationSourceBuilder(); builder.ConfigureSecurity() .AuthorizeUsingCustomProviderNamed("custom authz", typeof(IAuthorizationProvider)) .AuthorizeUsingRuleProviderNamed("ruleProvider") .SpecifyRule("rule1", "true") .SpecifyRule("rule2", "false") .CacheSecurityInCacheStoreNamed("cache Storage").WithOptions.UseSharedCacheManager("cache"); DictionaryConfigurationSource source = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); securitySettings = (SecuritySettings)source.GetSection(SecuritySettings.SectionName); }
protected override void Arrange() { base.Arrange(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureLogging().LogToCategoryNamed("General").SendTo.EventLog("Listener").SendTo.Msmq("msmqListener"); DesignDictionaryConfigurationSource source = new DesignDictionaryConfigurationSource(); sourceBuilder.UpdateConfigurationWithReplace(source); var applicationModel = Container.Resolve<ApplicationViewModel>(); var sourceModel = applicationModel.CurrentConfigurationSource; sourceModel.Load(source); foreach (var element in sourceModel.Sections.SelectMany(x => x.DescendentElements())) element.InheritedFromParentConfiguration = false; applicationModel.NewEnvironment(); Environment = applicationModel.Environments.First(); LoggingSectionViewModel = sourceModel.Sections.Where(x => x.SectionName == LoggingSettings.SectionName).First(); }
protected override void Arrange() { base.Arrange(); var builder = new ConfigurationSourceBuilder(); builder.ConfigureData() .ForDatabaseNamed("SomeOracleDatabase") .ThatIs.AnOracleDatabase() .WithConnectionString("SomeOracleConnectionString") .ForDatabaseNamed("SomeOleDbDatabase") .ThatIs.AnOleDbDatabase() .WithConnectionString("Some OleDb ConnectionString") .AsDefault(); var source = new DictionaryConfigurationSource(); builder.UpdateConfigurationWithReplace(source); var configSourceModel = Container.Resolve<ConfigurationSourceModel>(); configSourceModel.AddSection(DatabaseSettings.SectionName, source.GetSection(DatabaseSettings.SectionName)); ConnectionStringSection = configSourceModel.AddSection("connectionStrings", source.GetSection("connectionStrings")); }
protected override void Arrange() { base.Arrange(); DictionaryConfigurationSource source = new DictionaryConfigurationSource(); ConfigurationSourceBuilder sourceBuilder = new ConfigurationSourceBuilder(); sourceBuilder.ConfigureCaching() .ForCacheManagerNamed("Cache Manager 1") .StoreInMemory() .ForCacheManagerNamed("Cache Manager 2") .StoreInSharedBackingStore("database store") .ForCacheManagerNamed("Cache Manager 3") .StoreCacheMangerItemsInDatabase("database store") .EncryptUsing.SymmetricEncryptionProviderNamed("crypto thingy") .UsingSharedSymmetricEncryptionInstanceNamed("symm instance"); sourceBuilder.UpdateConfigurationWithReplace(source); CachingConfiguration = (CacheManagerSettings)source.GetSection(CacheManagerSettings.SectionName); var sourceModel = Container.Resolve<ConfigurationSourceModel>(); CachingViewModel = sourceModel.AddSection(CacheManagerSettings.SectionName, CachingConfiguration); }