本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}