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


C# Config.ToText方法代码示例

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


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

示例1: Test003_PutRemote

		public virtual void Test003_PutRemote()
		{
			Config c = new Config();
			c.SetString("sec", "ext", "name", "value");
			c.SetString("sec", "ext", "name2", "value2");
			string expText = "[sec \"ext\"]\n\tname = value\n\tname2 = value2\n";
			NUnit.Framework.Assert.AreEqual(expText, c.ToText());
		}
开发者ID:shoff,项目名称:ngit,代码行数:8,代码来源:ConfigTest.cs

示例2: TestSetEnum

 public virtual void TestSetEnum()
 {
     Config c = new Config();
     c.SetEnum("s", "b", "c", ConfigTest.TestEnum.ONE_TWO);
     NUnit.Framework.Assert.AreEqual("[s \"b\"]\n\tc = one two\n", c.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:6,代码来源:ConfigTest.cs

示例3: TestQuotingForSubSectionNames

 public virtual void TestQuotingForSubSectionNames()
 {
     string resultPattern = "[testsection \"{0}\"]\n\ttestname = testvalue\n";
     string result;
     Config config = new Config();
     config.SetString("testsection", "testsubsection", "testname", "testvalue");
     result = MessageFormat.Format(resultPattern, "testsubsection");
     NUnit.Framework.Assert.AreEqual(result, config.ToText());
     config.Clear();
     config.SetString("testsection", "#quotable", "testname", "testvalue");
     result = MessageFormat.Format(resultPattern, "#quotable");
     NUnit.Framework.Assert.AreEqual(result, config.ToText());
     config.Clear();
     config.SetString("testsection", "with\"quote", "testname", "testvalue");
     result = MessageFormat.Format(resultPattern, "with\\\"quote");
     NUnit.Framework.Assert.AreEqual(result, config.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:17,代码来源:ConfigTest.cs

示例4: TestEmptyString

 public virtual void TestEmptyString()
 {
     Config c = Parse("[my]\n\tempty =\n");
     NUnit.Framework.Assert.IsNull(c.GetString("my", null, "empty"));
     string[] values = c.GetStringList("my", null, "empty");
     NUnit.Framework.Assert.IsNotNull(values);
     NUnit.Framework.Assert.AreEqual(1, values.Length);
     NUnit.Framework.Assert.IsNull(values[0]);
     // always matches the default, because its non-boolean
     NUnit.Framework.Assert.IsTrue(c.GetBoolean("my", "empty", true));
     NUnit.Framework.Assert.IsFalse(c.GetBoolean("my", "empty", false));
     NUnit.Framework.Assert.AreEqual("[my]\n\tempty =\n", c.ToText());
     c = new Config();
     c.SetStringList("my", null, "empty", Arrays.AsList(values));
     NUnit.Framework.Assert.AreEqual("[my]\n\tempty =\n", c.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:16,代码来源:ConfigTest.cs

示例5: Test005_PutGetStringList

 public virtual void Test005_PutGetStringList()
 {
     Config c = new Config();
     List<string> values = new List<string>();
     values.AddItem("value1");
     values.AddItem("value2");
     c.SetStringList("my", null, "somename", values);
     object[] expArr = Sharpen.Collections.ToArray(values);
     string[] actArr = c.GetStringList("my", null, "somename");
     NUnit.Framework.Assert.IsTrue(Arrays.Equals(expArr, actArr));
     string expText = "[my]\n\tsomename = value1\n\tsomename = value2\n";
     NUnit.Framework.Assert.AreEqual(expText, c.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:13,代码来源:ConfigTest.cs

示例6: Test004_PutGetSimple

 public virtual void Test004_PutGetSimple()
 {
     Config c = new Config();
     c.SetString("my", null, "somename", "false");
     NUnit.Framework.Assert.AreEqual("false", c.GetString("my", null, "somename"));
     NUnit.Framework.Assert.AreEqual("[my]\n\tsomename = false\n", c.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:7,代码来源:ConfigTest.cs

示例7: TestTreeIteratorWithGitmodules

		public virtual void TestTreeIteratorWithGitmodules()
		{
			ObjectId subId = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			Config gitmodules = new Config();
			gitmodules.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_PATH, "sub");
			gitmodules.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_URL, "git://example.com/sub");
			RevCommit commit = testDb.GetRevWalk().ParseCommit(testDb.Commit().NoParents().Add
				(Constants.DOT_GIT_MODULES, gitmodules.ToText()).Edit(new _PathEdit_397(subId, path
				)).Create());
			CanonicalTreeParser p = new CanonicalTreeParser();
			p.Reset(testDb.GetRevWalk().GetObjectReader(), commit.Tree);
			SubmoduleWalk gen = SubmoduleWalk.ForPath(db, p, "sub");
			NUnit.Framework.Assert.AreEqual(path, gen.GetPath());
			NUnit.Framework.Assert.AreEqual(subId, gen.GetObjectId());
			NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), gen.GetDirectory
				());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUpdate());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUrl());
			NUnit.Framework.Assert.AreEqual("sub", gen.GetModulesPath());
			NUnit.Framework.Assert.IsNull(gen.GetModulesUpdate());
			NUnit.Framework.Assert.AreEqual("git://example.com/sub", gen.GetModulesUrl());
			NUnit.Framework.Assert.IsNull(gen.GetRepository());
			NUnit.Framework.Assert.IsFalse(gen.Next());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:27,代码来源:SubmoduleWalkTest.cs

示例8: IndexWithGitmodules

		public virtual void IndexWithGitmodules()
		{
			ObjectId subId = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			Config gitmodules = new Config();
			gitmodules.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_PATH, "sub");
			// Different config in the index should be overridden by the working tree.
			gitmodules.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_URL, "git://example.com/bad");
			RevBlob gitmodulesBlob = testDb.Blob(gitmodules.ToText());
			gitmodules.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_URL, "git://example.com/sub");
			WriteTrashFile(Constants.DOT_GIT_MODULES, gitmodules.ToText());
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_315(subId, path));
			editor.Add(new _PathEdit_322(gitmodulesBlob, Constants.DOT_GIT_MODULES));
			editor.Commit();
			SubmoduleWalk gen = SubmoduleWalk.ForIndex(db);
			NUnit.Framework.Assert.IsTrue(gen.Next());
			NUnit.Framework.Assert.AreEqual(path, gen.GetPath());
			NUnit.Framework.Assert.AreEqual(subId, gen.GetObjectId());
			NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), gen.GetDirectory
				());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUpdate());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUrl());
			NUnit.Framework.Assert.AreEqual("sub", gen.GetModulesPath());
			NUnit.Framework.Assert.IsNull(gen.GetModulesUpdate());
			NUnit.Framework.Assert.AreEqual("git://example.com/sub", gen.GetModulesUrl());
			NUnit.Framework.Assert.IsNull(gen.GetRepository());
			NUnit.Framework.Assert.IsFalse(gen.Next());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:33,代码来源:SubmoduleWalkTest.cs


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