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


C# ConfigurationSection.Set方法代码示例

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


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

示例1: GetSingleSection

 public static IConfigurationSection GetSingleSection()
 {
     IConfigurationSection section = new ConfigurationSection( "Default" );
     section.Set( "a", "a" );
     section.Set( "b", "b" );
     section.Set( "c", "c" );
     section.Set( "d", "d" );
     section.Set( "e", "e" );
     return section;
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:10,代码来源:SectionGenerator.cs

示例2: GetTwoSections

 public static IEnumerable<IConfigurationSection> GetTwoSections()
 {
     IConfigurationSection section = new ConfigurationSection( "Default" );
     section.Set( "a", "a" );
     section.Set( "b", "b" );
     IConfigurationSection section2 = new ConfigurationSection( "Default2" );
     section2.Set( "c", "c" );
     section2.Set( "d", "d" );
     section2.Set( "e", "e" );
     return new[] { section, section2 };
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:11,代码来源:SectionGenerator.cs

示例3: 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

示例4: GetConfigurationSource

 protected static ConfigurationSourceBaseImpl GetConfigurationSource()
 {
     var section = new ConfigurationSection( SectionName );
     var source = new ConfigurationSourceBaseImpl {section};
     section.Set( Key, Value );
     return source;
 }
开发者ID:chKarner,项目名称:innovatian.configuration,代码行数:7,代码来源:ConfigurationSourceBaseTests.cs

示例5: CanRemoveAddedValue

 public void CanRemoveAddedValue()
 {
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Value );
     bool success = section.Remove( Key );
     Assert.True( success );
 }
开发者ID:idavis,项目名称:innovatian.configuration,代码行数:7,代码来源:ConfigurationSectionTests.cs

示例6: 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

示例7: 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

示例8: CanReadAddedValueWithTryGet

 public void CanReadAddedValueWithTryGet()
 {
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Value );
     string value;
     bool found = section.TryGet( "key", out value );
     Assert.True( found );
     Assert.Equal( Value, value );
 }
开发者ID:idavis,项目名称:innovatian.configuration,代码行数:9,代码来源:ConfigurationSectionTests.cs

示例9: AddingNewSectionOverridesKeys

        public void AddingNewSectionOverridesKeys()
        {
            ConfigurationSourceBaseImpl source = GetConfigurationSource();
            var section = new ConfigurationSection( SectionName );
            section.Set( Key, Key );

            Assert.Equal( Value, source.Sections[SectionName].Get<string>( Key ) );
            source.Add( section );
            Assert.Equal( Key, source.Sections[SectionName].Get<string>( Key ) );
        }
开发者ID:chKarner,项目名称:innovatian.configuration,代码行数:10,代码来源:ConfigurationSourceBaseTests.cs

示例10: MergingWithCollectionOverwritesExistingKeys

 public void MergingWithCollectionOverwritesExistingKeys()
 {
     ConfigurationSourceBaseImpl source = GetConfigurationSource();
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Key );
     var source2 = new ConfigurationSourceBaseImpl {section};
     Assert.Equal( Value, source.Sections[SectionName].Get<string>( Key ) );
     source.Merge( new[] {source2} );
     Assert.Equal( Key, source.Sections[SectionName].Get<string>( Key ) );
 }
开发者ID:chKarner,项目名称:innovatian.configuration,代码行数:10,代码来源:ConfigurationSourceBaseTests.cs

示例11: MergingWithCollectionAddsConfigurationSection

 public void MergingWithCollectionAddsConfigurationSection()
 {
     ConfigurationSourceBaseImpl source = GetConfigurationSource();
     const string sectionName = SectionName + Key;
     var section = new ConfigurationSection( sectionName );
     section.Set( Key, Key );
     var source2 = new ConfigurationSourceBaseImpl {section};
     source.Merge( new[] {source2} );
     Assert.Contains( section, source );
 }
开发者ID:chKarner,项目名称:innovatian.configuration,代码行数:10,代码来源:ConfigurationSourceBaseTests.cs

示例12: EnumeratorGivesKeysAndValues

 public void EnumeratorGivesKeysAndValues()
 {
     var section = new ConfigurationSection( SectionName );
     section.Set( Key, Value );
     int count = 0;
     foreach ( KeyValuePair<string, string> pair in section )
     {
         Assert.Equal( Key, pair.Key );
         Assert.Equal( Value, pair.Value );
         count++;
     }
     Assert.Equal( 1, count );
 }
开发者ID:idavis,项目名称:innovatian.configuration,代码行数:13,代码来源:ConfigurationSectionTests.cs

示例13: 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

示例14: CreateConfigurationSection

 private void CreateConfigurationSection( string current, IEnumerable<KeyValuePair<string, string>> items )
 {
     var currentSection = new ConfigurationSection( current );
     foreach ( KeyValuePair<string, string> item in items )
     {
         currentSection.Set( item.Key, item.Value );
     }
     Add( currentSection );
 }
开发者ID:idavis,项目名称:Vulcan,代码行数:9,代码来源:DotNetConfigurationSource.cs

示例15: GetSection

        private IConfigurationSection GetSection( string subKey, string sectionName )
        {
            IConfigurationSection section = null;
            using ( RegistryKey key = GetKey( subKey, ref sectionName, RegistryKeyPermissionCheck.Default ) )
            {
                if ( key == null )
                {
                    return section;
                }

                section = new ConfigurationSection( sectionName );
                foreach ( string valueName in key.GetValueNames() )
                {
                    string name = valueName;
                    if ( string.IsNullOrEmpty( valueName ) )
                    {
                        name = DefaultKeyName;
                    }
                    object value = key.GetValue( valueName );
                    //string stringValue = SettingConverter.GetStringFromT( value );
                    switch ( key.GetValueKind( valueName ) )
                    {
                        case RegistryValueKind.Binary:
                            section.Set( name, (byte[]) value );
                            break;
                        case RegistryValueKind.DWord:
                            section.Set( name, (int) value );
                            break;
                        case RegistryValueKind.ExpandString:
                            section.Set( name, (string) value );
                            break;
                        case RegistryValueKind.MultiString:
                            section.Set( name, (string[]) value );
                            break;
                        case RegistryValueKind.QWord:
                            section.Set( name, (long) value );
                            break;
                        case RegistryValueKind.String:
                            section.Set( name, (string) value );
                            break;
                        case RegistryValueKind.Unknown:
                            section.Set( name, value );
                            break;
                    }
                }
            }
            return section;
        }
开发者ID:idavis,项目名称:Vulcan,代码行数:48,代码来源:RegistryConfigurationSource.cs


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