本文整理汇总了C#中Config.setString方法的典型用法代码示例。如果您正苦于以下问题:C# Config.setString方法的具体用法?C# Config.setString怎么用?C# Config.setString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config.setString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: test003_PutRemote
public 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";
Assert.AreEqual(expText, c.toText());
}
示例2: PutGetSimple
public void PutGetSimple()
{
Config c = new Config();
c.setString("my", null, "somename", "false");
Assert.AreEqual("false", c.getString("my", null, "somename"));
Assert.AreEqual("[my]\n\tsomename = false\n", c.toText());
}
示例3: Set
private void Set(Config rc, string key, string currentValue, IEquatable<string> defaultValue)
{
if (defaultValue.Equals(currentValue))
{
Unset(rc, key);
}
else
{
rc.setString(Section, Name, key, currentValue);
}
}
示例4: test007_readUserConfig
public void test007_readUserConfig()
{
MockSystemReader mockSystemReader = new MockSystemReader();
SystemReader.setInstance(mockSystemReader);
string hostname = mockSystemReader.getHostname();
Config userGitConfig = mockSystemReader.userGitConfig;
Config localConfig = new Config(userGitConfig);
mockSystemReader.values.Clear();
string authorName;
string authorEmail;
// no values defined nowhere
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);
// the system user name is defined
mockSystemReader.values.put(Constants.OS_USER_NAME_KEY, "os user name");
localConfig.uncache(UserConfig.KEY);
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
Assert.AreEqual("os user name", authorName);
if (hostname != null && hostname.Length != 0)
{
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("os user [email protected]" + hostname, authorEmail);
}
// the git environment variables are defined
mockSystemReader.values.put(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
mockSystemReader.values.put(Constants.GIT_AUTHOR_EMAIL_KEY, "[email protected]");
localConfig.uncache(UserConfig.KEY);
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("git author name", authorName);
Assert.AreEqual("[email protected]", authorEmail);
// the values are defined in the global configuration
userGitConfig.setString("user", null, "name", "global username");
userGitConfig.setString("user", null, "email", "[email protected]");
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("global username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
// the values are defined in the local configuration
localConfig.setString("user", null, "name", "local username");
localConfig.setString("user", null, "email", "[email protected]");
authorName = localConfig.get(UserConfig.KEY).getAuthorName();
authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
Assert.AreEqual("local username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
authorName = localConfig.get(UserConfig.KEY).getCommitterName();
authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail();
Assert.AreEqual("local username", authorName);
Assert.AreEqual("[email protected]", authorEmail);
}