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


C# Config.setString方法代码示例

本文整理汇总了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());
 }
开发者ID:Squelch,项目名称:GitSharp,代码行数:8,代码来源:RepositoryConfigTest.cs

示例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());
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:7,代码来源:RepositoryConfigTest.cs

示例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);
			}
		}
开发者ID:dev218,项目名称:GitSharp,代码行数:11,代码来源:RemoteConfig.cs

示例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);
        }
开发者ID:Squelch,项目名称:GitSharp,代码行数:60,代码来源:RepositoryConfigTest.cs


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