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


C# ConfigurationSection.Get方法代码示例

本文整理汇总了C#中ConfigurationSection.Get方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationSection.Get方法的具体用法?C# ConfigurationSection.Get怎么用?C# ConfigurationSection.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanReadAddedValue

 public void CanReadAddedValue()
 {
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Value );
     var value = section.Get<string>( "key" );
     Assert.Equal( Value, value );
 }
开发者ID:idavis,项目名称:innovatian.configuration,代码行数:7,代码来源:ConfigurationSectionTests.cs

示例2: CanGetAndSetEnumStringValues

 public void CanGetAndSetEnumStringValues()
 {
     const OSEnum value = OSEnum.Win2k;
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, value.ToString() );
     var fromSection = section.Get<OSEnum>( Key );
     Assert.AreEqual( value, fromSection );
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:8,代码来源:ConfigurationSectionTests.cs

示例3: CanGetAndSetEnumFlagValues

 public void CanGetAndSetEnumFlagValues()
 {
     const OptionsEnum all = ( OptionsEnum.A | OptionsEnum.B | OptionsEnum.C );
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, all );
     var fromSection = section.Get<OptionsEnum>( Key );
     Assert.AreEqual( all, fromSection );
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:8,代码来源:ConfigurationSectionTests.cs

示例4: SettingAValueForAnExistingKeyOverrides

 public void SettingAValueForAnExistingKeyOverrides()
 {
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Value );
     Assert.AreEqual( Value, section.Get<string>( Key ) );
     section.Set( Key, Key );
     Assert.AreEqual( Key, section.Get<string>( Key ) );
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:8,代码来源:ConfigurationSectionTests.cs

示例5: GettingNonExistingItemReturnsDefaultForType

        public void GettingNonExistingItemReturnsDefaultForType()
        {
            var section = new ConfigurationSection( SectionName );
            var optionsEnum = section.Get<OptionsEnum>( Key );
            Assert.AreEqual( default( OptionsEnum ), optionsEnum );

            var osEnum = section.Get<OSEnum>( Key );
            Assert.AreEqual( default( OSEnum ), osEnum );

            var stringValue = section.Get<string>( Key );
            Assert.AreEqual( default( string ), stringValue );

            var boolValue = section.Get<bool>( Key );
            Assert.AreEqual( default( bool ), boolValue );

            var dummySection = section.Get<ConfigurationSection>( Key );
            Assert.AreEqual( default( ConfigurationSection ), dummySection );
        }
开发者ID:idavis,项目名称:Vulcan,代码行数:18,代码来源:ConfigurationSectionTests.cs

示例6: DefaultParameterValueIsReturnedForNonExistingKey

        public void DefaultParameterValueIsReturnedForNonExistingKey()
        {
            var section = new ConfigurationSection( SectionName );

            const OptionsEnum optionsEnumDefault = OptionsEnum.None;
            OptionsEnum optionsEnum = section.Get( Key, optionsEnumDefault );
            Assert.AreEqual( optionsEnumDefault, optionsEnum );

            const OSEnum osEnumDefault = OSEnum.WinXp;
            OSEnum osEnum = section.Get( Key, osEnumDefault );
            Assert.AreEqual( osEnumDefault, osEnum );

            const string stringDefault = Value;
            string stringValue = section.Get( Key, stringDefault );
            Assert.AreEqual( stringDefault, stringValue );

            bool boolValue = section.Get( Key, true );
            Assert.AreEqual( true, boolValue );

            boolValue = section.Get( Key, false );
            Assert.AreEqual( false, boolValue );

            var defaultSection = new ConfigurationSection( "MyDefault" );
            ConfigurationSection dummySection = section.Get( Key, defaultSection );
            Assert.AreEqual( defaultSection, dummySection );
        }
开发者ID:idavis,项目名称:Vulcan,代码行数:26,代码来源:ConfigurationSectionTests.cs

示例7: CanGetAndSetEnumInt32Values

 public void CanGetAndSetEnumInt32Values()
 {
     const OSEnum value = OSEnum.Win2k;
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, (int) value );
     var fromSection = section.Get<OSEnum>( Key );
     Assert.Equal( value, fromSection );
 }
开发者ID:idavis,项目名称:innovatian.configuration,代码行数:8,代码来源:ConfigurationSectionTests.cs


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