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


C# IConfigSource.ToString方法代码示例

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


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

示例1: WriteConfigFile

 private void WriteConfigFile(int i, IConfigSource m_config)
 {
     string m_fileName = "ConfigFileDump" + i + ".ini";
     Console.WriteLine(string.Format("Writing config dump file to " + m_fileName));
     try
     {
         //Add the user
         FileStream stream = new FileStream(m_fileName, FileMode.Create);
         StreamWriter m_streamWriter = new StreamWriter(stream);
         m_streamWriter.BaseStream.Position += m_streamWriter.BaseStream.Length;
         m_streamWriter.WriteLine(m_config.ToString());
         m_streamWriter.Close();
     }
     catch
     {
     }
 }
开发者ID:emperorstarfinder,项目名称:Virtual-Universe,代码行数:17,代码来源:ConfigurationLoader.cs

示例2: IncludeTests

        public void IncludeTests()
        {
            const string mainIniFile = "OpenSimDefaults.ini";
            m_config = new IniConfigSource();

            // Create ini files in a directory structure
            IniConfigSource ini;
            IConfig config;

            ini = new IniConfigSource();
            config = ini.AddConfig("IncludeTest");
            config.Set("Include-absolute", "absolute/*/config/*.ini");
            config.Set("Include-relative", "../" + m_testSubdirectory + "/relative/*/config/*.ini");
            CreateIni(mainIniFile, ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute1").Set("name1", "value1");
            CreateIni("absolute/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name2", 2.3);
            CreateIni("absolute/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name3", "value3");
            CreateIni("absolute/two/config/setting2.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative1").Set("name4", "value4");
            CreateIni("relative/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name5", true);
            CreateIni("relative/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name6", 6);
            CreateIni("relative/two/config/setting2.ini", ini);

            // Prepare call to ConfigurationLoader.LoadConfigSettings()
            ConfigurationLoader cl = new ConfigurationLoader();
            IConfigSource argvSource = new IniConfigSource();
            EnvConfigSource envConfigSource = new EnvConfigSource();
            argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
            ConfigSettings configSettings;
            NetworkServersInfo networkInfo;

            OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, envConfigSource,
                out configSettings, out networkInfo);

            // Remove default config
            config = source.Source.Configs["Startup"];
            source.Source.Configs.Remove(config);
            config = source.Source.Configs["Network"];
            source.Source.Configs.Remove(config);

            // Finally, we are able to check the result
            Assert.AreEqual(m_config.ToString(), source.Source.ToString(),
                "Configuration with includes does not contain all settings.");
            // The following would be preferable but fails due to a type mismatch which I am not able to resolve
            //CollectionAssert.AreEquivalent(m_config.Configs, source.Source.Configs,
            //    String.Format("Configuration with includes does not contain all settings.\nAll settings:\n{0}\nSettings read:\n{1}", m_config, source.Source));
        }
开发者ID:justasabc,项目名称:opensim75grid,代码行数:63,代码来源:ConfigurationLoaderTest.cs


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