• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ConfigurationSection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Start

		public void Start(ConfigurationSection configuration) {
			_tokenDistributor = new System.Timers.Timer();
			_tokenDistributor.Elapsed += new System.Timers.ElapsedEventHandler(TokenDistributor_Elapsed);
			_tokenDistributor.Interval = _interval;
			_tokenDistributor.AutoReset = true;
			_tokenDistributor.Enabled = true;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:SimpleBWControlService.cs


示例2: Parse

 public IEnumerable<ConfigurationEntry> Parse(string data)
 {
     ConfigurationSection currentSection = null;
     foreach (var line in data.Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
     {
         var sectionMatch = _configurationSectionRegex.Match(line);
         if (sectionMatch.Success)
         {
             if (currentSection != null)
                 yield return currentSection;
             currentSection = new ConfigurationSection
             {
                 Type = sectionMatch.Groups["type"].Value,
                 Name = sectionMatch.Groups["name"].Success ? sectionMatch.Groups["name"].Value : string.Empty
             };
             continue;
         }
         var lineMatch = _configurationLineRegex.Match(line);
         if (lineMatch.Success)
         {
             var configLine = new ConfigurationLine
             {
                 Name = lineMatch.Groups["name"].Value,
                 Value = lineMatch.Groups["value"].Value
             };
             if (currentSection != null)
                 currentSection.Lines.Add(configLine);
             else
                 yield return configLine;
         }
     }
     if (currentSection != null)
         yield return currentSection;
 }
开发者ID:modulexcite,项目名称:openwrap,代码行数:34,代码来源:ConfigurationParser.cs


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


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


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


示例6: GetInstance

		public static ConfigurationSection GetInstance()
		{
			if (instance == null)
			{
				lock (typeof(ConfigurationSection))
				{
					try
					{	
#pragma warning disable 618
						instance = (ConfigurationSection)ConfigurationSettings.GetConfig("Platform/VirtualFileSystem/Multimedia/Configuration");
#pragma warning restore 618
					}
					catch (Exception e)
					{
						throw e.InnerException;
					}

					if (instance == null)
					{
						instance = new ConfigurationSection();
					}
				}
			}

			return instance;
		}
开发者ID:vector-man,项目名称:Platform.VirtualFileSystem,代码行数:26,代码来源:ConfigurationSection.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: CanGetAndSetEnumValues

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


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


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


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


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


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


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


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


示例16: Should_be_possible_get_a_valid_configuration_from_a_section_object

        public void Should_be_possible_get_a_valid_configuration_from_a_section_object()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = MockRepository.GenerateStub<IConfigurationView>();
            var fakeController = mocks.DynamicMock<ConfigurationController>(new object[] { fakeView });

            var fakeConfigurationSection = new ConfigurationSection();
            fakeConfigurationSection.server.Address = "http://localhost";
            fakeConfigurationSection.server.Port = "1024";
            fakeConfigurationSection.server.Username = "admin";
            fakeConfigurationSection.server.Password = "PassworD";

            fakeConfigurationSection.target.Address = "10.0.0.1";
            fakeConfigurationSection.target.Username = "administrator";
            fakeConfigurationSection.target.Password = "[email protected]";
            fakeConfigurationSection.target.AdministrativePassword = "qwerty";

            fakeConfigurationSection.file.SaveFolder = "C:\\Temp\\";
            fakeConfigurationSection.file.DefinitionFilename = "C:\\Temp\\definitions.xml";

            using (mocks.Record())
            {
                Expect.Call(fakeController.FileExists(null)).IgnoreArguments().Return(true);
                Expect.Call(fakeController.ReadConfigurationSection(null)).IgnoreArguments().Return(fakeConfigurationSection);
            }

            mocks.ReplayAll();

            fakeController.view_OnReadConfiguration(this, EventArgs.Empty);

            mocks.VerifyAll();

            Assert.IsNotNull(fakeView.Server);
            Assert.AreEqual("http://localhost", fakeView.Server.Address);
            Assert.AreEqual("1024", fakeView.Server.Port);
            Assert.AreEqual("admin", fakeView.Server.Username);
            Assert.AreEqual("PassworD", fakeView.Server.Password);

            Assert.IsNotNull(fakeView.Target);
            Assert.AreEqual("10.0.0.1", fakeView.Target.Address);
            Assert.AreEqual("administrator", fakeView.Target.Username);
            Assert.AreEqual("[email protected]", fakeView.Target.Password);
            Assert.AreEqual("qwerty", fakeView.Target.AdministrativePassword);

            Assert.IsNotNull(fakeView.DestinationFolder);
            Assert.AreEqual("C:\\Temp\\", fakeView.DestinationFolder);
            Assert.IsNotNull(fakeView.DefinitionFilename);
            Assert.AreEqual("C:\\Temp\\definitions.xml", fakeView.DefinitionFilename);
        }
开发者ID:jonaslsl,项目名称:modSIC,代码行数:50,代码来源:ConfigurationControllerTest.cs


示例17: GetInstance

 public static ConfigurationSection GetInstance()
 {
     try
     {
         if (instance == null)
         {
             instance = (ConfigurationSection)ConfigurationManager.GetSection("searchEngineConfiguration");
         }
         return instance;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
开发者ID:vinasourcetutran,项目名称:searchengine,代码行数:15,代码来源:Configuration.cs


示例18: TryGetSubSection

        public override bool TryGetSubSection(string key, out ConfigurationSection sect)
        {
            if (ParentConfig == null)
            {
                throw new InvalidOperationException();
            }

            string res;
            if (TryGetValue(key, out res))
            {
                sect = ParentConfig[res];
                return true;
            }
            sect = null;
            return false;
        }
开发者ID:yuri410,项目名称:lrvbsvnicg,代码行数:16,代码来源:GameConfigurationSection.cs


示例19: DiskBackupManager

        public DiskBackupManager(ConfigurationSection configSection, string partitionId, long keymin, long keymax, string codePackageTempDirectory)
        {
            this.keyMin = keymin;
            this.keyMax = keymax;

            string BackupArchivalPath = configSection.Parameters["BackupArchivalPath"].Value;
            this.backupFrequencyInSeconds = long.Parse(configSection.Parameters["BackupFrequencyInSeconds"].Value);
            this.MaxBackupsToKeep = int.Parse(configSection.Parameters["MaxBackupsToKeep"].Value);

            this.PartitionArchiveFolder = Path.Combine(BackupArchivalPath, "Backups", partitionId);
            this.PartitionTempDirectory = Path.Combine(codePackageTempDirectory, partitionId);

            ServiceEventSource.Current.Message(
                "DiskBackupManager constructed IntervalinSec:{0}, archivePath:{1}, tempPath:{2}, backupsToKeep:{3}",
                this.backupFrequencyInSeconds,
                this.PartitionArchiveFolder,
                this.PartitionTempDirectory,
                this.MaxBackupsToKeep);
        }
开发者ID:smartpcr,项目名称:service-fabric-dotnet-web-reference-app,代码行数:19,代码来源:LocalBackupStore.cs


示例20: AzureBlobBackupManager

        public AzureBlobBackupManager(ConfigurationSection configSection, string partitionId, long keymin, long keymax, string codePackageTempDirectory)
        {
            this.keyMin = keymin;
            this.keyMax = keymax;

            string backupAccountName = configSection.Parameters["BackupAccountName"].Value;
            string backupAccountKey = configSection.Parameters["PrimaryKeyForBackupTestAccount"].Value;
            string blobEndpointAddress = configSection.Parameters["BlobServiceEndpointAddress"].Value;

            this.backupFrequencyInSeconds = long.Parse(configSection.Parameters["BackupFrequencyInSeconds"].Value);
            this.MaxBackupsToKeep = int.Parse(configSection.Parameters["MaxBackupsToKeep"].Value);
            this.partitionId = partitionId;
            this.PartitionTempDirectory = Path.Combine(codePackageTempDirectory, partitionId);

            StorageCredentials storageCredentials = new StorageCredentials(backupAccountName, backupAccountKey);
            this.cloudBlobClient = new CloudBlobClient(new Uri(blobEndpointAddress), storageCredentials);
            this.backupBlobContainer = this.cloudBlobClient.GetContainerReference(this.partitionId);
            this.backupBlobContainer.CreateIfNotExists();
        }
开发者ID:smartpcr,项目名称:service-fabric-dotnet-web-reference-app,代码行数:19,代码来源:AzureBackupStore.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConfigurationSource类代码示例发布时间:2022-05-24
下一篇:
C# ConfigurationSaveMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap