当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.DictionaryConfigurationSource类代码示例

本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Common.Configuration.DictionaryConfigurationSource的典型用法代码示例。如果您正苦于以下问题:C# DictionaryConfigurationSource类的具体用法?C# DictionaryConfigurationSource怎么用?C# DictionaryConfigurationSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DictionaryConfigurationSource类属于Microsoft.Practices.EnterpriseLibrary.Common.Configuration命名空间,在下文中一共展示了DictionaryConfigurationSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Arrange

        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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:29,代码来源:when_requesting_child_properties.cs

示例2: RegisterEnterpriseLibrary_NullContainerBuilder

 public void RegisterEnterpriseLibrary_NullContainerBuilder()
 {
     ContainerBuilder builder = null;
     var source = new DictionaryConfigurationSource();
     Assert.Throws<ArgumentNullException>(() => builder.RegisterEnterpriseLibrary());
     Assert.Throws<ArgumentNullException>(() => builder.RegisterEnterpriseLibrary(source));
 }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:7,代码来源:EnterpriseLibraryRegistrationExtensionsFixture.cs

示例3: Setup

        public void Setup()
        {
            var configSource = new DictionaryConfigurationSource();

            configSource.Add(DatabaseSettings.SectionName, new DatabaseSettings { DefaultDatabase = "default" });
            configSettings = new DatabaseSyntheticConfigSettings(configSource);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:DatabaseSyntheticConfigurationSettingsFixture.cs

示例4: ConfigureLogging

        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));
        }
开发者ID:rconnelly,项目名称:ach.fulfillment,代码行数:31,代码来源:InitializationContainerExtension.cs

示例5: Then_ConfigurationSourceContainsSecuritySettings

        public void Then_ConfigurationSourceContainsSecuritySettings()
        {
            IConfigurationSource source = new DictionaryConfigurationSource();
            configurationSourceBuilder.UpdateConfigurationWithReplace(source);

            Assert.IsNotNull(source.GetSection(SecuritySettings.SectionName));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:SecuritySettingsExtensionFixture.cs

示例6: GetSecuritySettings

        protected SecuritySettings GetSecuritySettings()
        {
            IConfigurationSource source = new DictionaryConfigurationSource();
            configurationSourceBuilder.UpdateConfigurationWithReplace(source);

            return (SecuritySettings)source.GetSection(SecuritySettings.SectionName);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:AuthorizeUsingAzManExtensionFixture.cs

示例7: Arrange

        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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:26,代码来源:LoggingConfigurationContext.cs

示例8: Then_ConfigurationSourceContainsTypeRegistrationProviderSettings

        public void Then_ConfigurationSourceContainsTypeRegistrationProviderSettings()
        {
            IConfigurationSource source = new DictionaryConfigurationSource();
            base.ConfigurationSourceBuilder.UpdateConfigurationWithReplace(source);

            Assert.IsNotNull(source.GetSection(TypeRegistrationProvidersConfigurationSection.SectionName));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:TypeRegistrationProviderConfigurationSourceBuilderExtensionFixture.cs

示例9: Setup

 public void Setup()
 {
     container = new UnityContainer();
     var configurationSource = new DictionaryConfigurationSource();
     new UnityContainerConfigurator(container)
         .RegisterAll(configurationSource, new ValidationTypeRegistrationProvider());
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:7,代码来源:ValidationCallHandlerAttributeFixture.cs

示例10: ShouldCreateCorrectMatchingRule

        public void ShouldCreateCorrectMatchingRule()
        {
            ValidationFactory.SetDefaultConfigurationValidatorFactory(new ConfigurationValidatorFactory(new DictionaryConfigurationSource()));

            PolicyData policyData = new PolicyData("Validate Parameters");
            policyData.Handlers.Add(new ValidationCallHandlerData());
            ParameterTypeMatchingRuleData matchingRuleData = GetParameterTypeMatchingRuleData();
            policyData.MatchingRules.Add(matchingRuleData);

            PolicyInjectionSettings settings = new PolicyInjectionSettings();
            settings.Policies.Add(policyData);

            DictionaryConfigurationSource configSource = new DictionaryConfigurationSource();
            configSource.Add(PolicyInjectionSettings.SectionName, settings);

            IUnityContainer container = new UnityContainer().AddNewExtension<Interception>();
            settings.ConfigureContainer(container);

            RuleDrivenPolicy policy = container.Resolve<RuleDrivenPolicy>("Validate Parameters");
            List<IMatchingRule> rules = RuleCreationFixture.GetRules(policy);

            Assert.IsNotNull(policy);
            Assert.IsTrue(rules[0] is ParameterTypeMatchingRule);
            ParameterTypeMatchingRule rule = (ParameterTypeMatchingRule)(rules[0]);
            Assert.AreEqual(3, rule.ParameterMatches.Count());
            for (int i = 0; i < matchingRuleData.Matches.Count; ++i)
            {
                AssertMatchDataEqual(
                    matchingRuleData.Matches[i],
                    rule.ParameterMatches.ElementAt(i),
                    "Mismatch at element {0}",
                    i);
            }
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:34,代码来源:ParameterTypeMatchingRuleDataFixture.cs

示例11: SetUp

 public void SetUp()
 {
     factory = new MockAssembledObjectFactory();
     context = new MockBuilderContext();
     configurationSource = new DictionaryConfigurationSource();
     reflectionCache = new ConfigurationReflectionCache();
 }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:7,代码来源:AssemblerBasedCustomFactoryFixture.cs

示例12: Setup

        public void Setup()
        {
            var configSource = new DictionaryConfigurationSource();

            configSource.Add(DatabaseSettings.SectionName, new DatabaseSettings());
            configSettings = new DatabaseSyntheticConfigSettings(configSource.GetSection);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:DatabaseSyntheticConfigurationSettingsFixture.cs

示例13: ManageabilityProviderGeneratesProperAdmContent

        public void ManageabilityProviderGeneratesProperAdmContent()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();

            configurationObject.Type = typeof(object);

            MockAdmContentBuilder contentBuilder = new MockAdmContentBuilder();

            contentBuilder.StartCategory("category");
            provider.AddAdministrativeTemplateDirectives(contentBuilder, configurationObject, configurationSource, "TestApp");
            contentBuilder.EndCategory();

            MockAdmContent content = contentBuilder.GetMockContent();
            IEnumerator<AdmCategory> categoriesEnumerator = content.Categories.GetEnumerator();
            categoriesEnumerator.MoveNext();
            IEnumerator<AdmPolicy> policiesEnumerator = categoriesEnumerator.Current.Policies.GetEnumerator();
            Assert.IsTrue(policiesEnumerator.MoveNext());
            IEnumerator<AdmPart> partsEnumerator = policiesEnumerator.Current.Parts.GetEnumerator();
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmEditTextPart), partsEnumerator.Current.GetType());
            Assert.IsNull(((AdmEditTextPart)partsEnumerator.Current).KeyName);
            Assert.IsTrue(partsEnumerator.MoveNext());
            Assert.AreSame(typeof(AdmEditTextPart), partsEnumerator.Current.GetType());
            Assert.IsNull(((AdmEditTextPart)partsEnumerator.Current).KeyName);
            Assert.IsFalse(partsEnumerator.MoveNext());
            Assert.IsFalse(policiesEnumerator.MoveNext());
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:27,代码来源:CustomCacheManagerDataManageabilityProviderFixture.cs

示例14: EntLib5UseCase

        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.");

        }
开发者ID:NServiceKit,项目名称:NServiceKit.Logging,代码行数:27,代码来源:UsingEntLib5.cs

示例15: ConfigureExceptionHandling

        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);
        }
开发者ID:quadio,项目名称:amss-boilerplate,代码行数:34,代码来源:ApiContainerExtension.cs


注:本文中的Microsoft.Practices.EnterpriseLibrary.Common.Configuration.DictionaryConfigurationSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。