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


C# ConfigFile.SetValue方法代码示例

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


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

示例1: SetGlobalDiffToolToConfig

 public static void SetGlobalDiffToolToConfig(ConfigFile configFile, string diffTool)
 {
     if (GitCommandHelpers.VersionInUse.GuiDiffToolExist)
     {
         configFile.SetValue("diff.guitool", diffTool);
         return;
     }
     configFile.SetValue("diff.tool", diffTool);
 }
开发者ID:JakeGinnivan,项目名称:gitextensions,代码行数:9,代码来源:CheckSettingsLogic.cs

示例2: CaseSensitive

        public void CaseSensitive()
        {
            // create test data
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
                configFile.SetValue("branch.BranchName1.remote", "origin1");
                configFile.Save();

                AddConfigValue(GetConfigFileName(), "branch.\"BranchName2\".remote", "origin2");
                AddConfigValue(GetConfigFileName(), "branch.\"branchName2\".remote", "origin3");
            }
            // verify
            {

                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);

                string remote = "branch.BranchName1.remote";
                CheckValueIsEqual(configFile, remote, "origin1");

                remote = "branch.branchName1.remote";
                CheckIsNotEqual(configFile, remote, "origin1");

                remote = "branch \"BranchName1\".remote";
                Assert.AreEqual(GetConfigValue(configFile.FileName, remote.Replace(" ", ".")), configFile.GetValue(remote), "git config --get");
                Assert.AreEqual("origin1", configFile.GetValue(remote), "ConfigFile");

                remote = "branch \"BranchName2\".remote";
                Assert.AreEqual(GetConfigValue(configFile.FileName, remote.Replace(" ", ".")), configFile.GetValue(remote), "git config --get");
                Assert.AreEqual("origin2", configFile.GetValue(remote), "ConfigFile");

                remote = "branch \"branchName2\".remote";
                Assert.AreNotEqual(GetConfigValue(configFile.FileName, remote.Replace(" ", ".")), "origin2", "git config --get");
                Assert.AreNotEqual("origin2", configFile.GetValue(remote), "ConfigFile");

                remote = "branch \"branchName2\".remote";
                Assert.AreEqual(GetConfigValue(configFile.FileName, remote.Replace(" ", ".")), configFile.GetValue(remote), "git config --get");
                Assert.AreEqual("origin3", configFile.GetValue(remote), "ConfigFile");

                remote = "branch \"branchname2\".remote";
                Assert.AreEqual(GetConfigValue(configFile.FileName, remote.Replace(" ", ".")), configFile.GetValue(remote), "git config --get");
                Assert.AreEqual("", configFile.GetValue(remote), "ConfigFile");
            }
        }
开发者ID:fraga,项目名称:gitextensionstest,代码行数:43,代码来源:ConfigFileTest.cs

示例3: CaseSensitive

        public void CaseSensitive()
        {
            // create test data
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
                configFile.SetValue("branch.BranchName1.remote", "origin1");
                configFile.Save();

                AddConfigValue(GetConfigFileName(), "branch.\"BranchName2\".remote", "origin2");
                AddConfigValue(GetConfigFileName(), "branch.\"branchName2\".remote", "origin3");
            }
            // verify
            {

                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);

                string remote = "branch.BranchName1.remote";
                Assert.AreEqual("origin1", configFile.GetValue(remote), remote);

                remote = "branch.branchName1.remote";
                Assert.AreNotEqual("origin1", configFile.GetValue(remote), remote);

                remote = "branch \"BranchName1\".remote";
                Assert.AreEqual("origin1", configFile.GetValue(remote), remote);

                remote = "branch \"BranchName2\".remote";
                Assert.AreEqual("origin2", configFile.GetValue(remote), remote);

                remote = "branch \"branchName2\".remote";
                Assert.AreNotEqual("origin2", configFile.GetValue(remote), remote);

                remote = "branch \"branchName2\".remote";
                Assert.AreEqual("origin3", configFile.GetValue(remote), remote);

                remote = "branch \"branchname2\".remote";
                Assert.AreEqual("", configFile.GetValue(remote), remote);

            }
        }
开发者ID:Copro,项目名称:gitextensionstest,代码行数:39,代码来源:ConfigFileTest.cs

示例4: TestWithHiddenFile

        public void TestWithHiddenFile()
        {
            { //TESTDATA
                //Write test config
                File.WriteAllText(GetConfigFileName(), GetDefaultConfigFileContent(), GitModule.SystemEncoding);

                //Make sure it is hidden
                FileInfo configFile = new FileInfo(GetConfigFileName());
                configFile.Attributes = FileAttributes.Hidden;
            }

            { //PERFORM TEST
                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
                CheckValueIsEqual(configFile, "section1.key1", "value1");
                CheckValueIsEqual(configFile, "section2.subsection.key2", "value2");
                CheckValueIsEqual(configFile, "section3.subsection.key3", "value3");

                configFile.SetValue("section1.key1", "newvalue1");
                configFile.Save();
            }

            //CHECK WRITTEN VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
                CheckValueIsEqual(configFile, "section1.key1", "newvalue1");
            }
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:27,代码来源:ConfigFileTest.cs

示例5: TestRemoveSettingSectionWithDotExisting

        public void TestRemoveSettingSectionWithDotExisting()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.SetValue("submodule.test.test1.path1", "invalid");
            configFile.SetValue("submodule.test.test2.path1", "submodule.test.test2.path1");
            configFile.SetValue("submodule.test.test2.path2", "submodule.test.test2.path2");
            configFile.Save();

            configFile.RemoveSetting("submodule.test.test1.path1");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            Assert.IsFalse(configFile.HasValue("submodule.test.test1.path1"));
            CheckValueIsEqual(configFile, "submodule.test.test2.path1", "submodule.test.test2.path1");
            CheckValueIsEqual(configFile, "submodule.test.test2.path2", "submodule.test.test2.path2");
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:16,代码来源:ConfigFileTest.cs

示例6: TestRemoveSettingNonExisting

        public void TestRemoveSettingNonExisting()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.SetValue("section2.key1", "section2.key1");
            configFile.SetValue("section1.key2", "section1.key2");
            configFile.Save();

            configFile.RemoveSetting("section1.key1");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            Assert.IsFalse(configFile.HasValue("section1.key1"));
            Assert.IsTrue(configFile.HasValue("section2.key1"));
            Assert.IsTrue(configFile.HasValue("section1.key2"));
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:15,代码来源:ConfigFileTest.cs

示例7: TestWithDirectories

        public void TestWithDirectories()
        {
            { //TESTDATA
                //Write test config
                File.WriteAllText(GetConfigFileName(), GetDefaultConfigFileContent(), Encoding.UTF8);
            }

            { //PERFORM TEST
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                configFile.SetValue("directory.first", @"c:\program files\gitextensions\gitextensions.exe");
                configFile.Save();
            }

            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual(@"c:/program files/gitextensions/gitextensions.exe", configFile.GetValue("directory.first"));
            }
        }
开发者ID:jystic,项目名称:gitextensions,代码行数:18,代码来源:ConfigFileTest.cs

示例8: TestWithHiddenFile

        public void TestWithHiddenFile()
        {
            { //TESTDATA
                //Write test config
                File.WriteAllText(GetConfigFileName(), GetDefaultConfigFileContent(), Encoding.UTF8);

                //Make sure it is hidden
                FileInfo configFile = new FileInfo(GetConfigFileName());
                configFile.Attributes = FileAttributes.Hidden;
            }

            { //PERFORM TEST
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("value1", configFile.GetValue("section1.key1"));
                Assert.AreEqual("value2", configFile.GetValue("section2.subsection.key2"));
                Assert.AreEqual("value3", configFile.GetValue("section3.subsection.key3"));

                configFile.SetValue("section1.key1", "newvalue1");
                configFile.Save();
            }

            //CHECK WRITTEN VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("newvalue1", configFile.GetValue("section1.key1"));
            }
        }
开发者ID:christruman,项目名称:gitextensions,代码行数:27,代码来源:ConfigFileTest.cs

示例9: RandomTestCase2

        public void RandomTestCase2()
        {
            { //TESTDATA
                StringBuilder content = new StringBuilder();

                content.AppendLine("[core]");
                content.AppendLine("	repositoryformatversion = 0");
                content.AppendLine("	filemode = false");
                content.AppendLine("	bare = false");
                content.AppendLine("	logallrefupdates = true");
                content.AppendLine("	symlinks = false");
                content.AppendLine("	ignorecase = true");
                content.AppendLine("	editor = C:/Program Files (x86)/Notepad++/notepad++.exe");
                content.AppendLine("[remote \"origin\"]");
                content.AppendLine("	fetch = +refs/heads/*:refs/remotes/origin/*");
                content.AppendLine("	url = [email protected]:SDWH_Project_01.git");
                content.AppendLine("	puttykeyfile = C:\\Users\\sergiy.pustovit\\spustovit_sintez_key_1.ppk");
                content.AppendLine("[branch \"master\"]");
                content.AppendLine("	remote = origin");
                content.AppendLine("	merge = refs/heads/master");
                content.AppendLine("[gui]");
                content.AppendLine("	geometry = 917x503+25+25 201 191");
                content.AppendLine("[merge]");
                content.AppendLine("	tool = kdiff3");
                content.AppendLine("[remote \"test\"]");
                content.AppendLine("	url = git-sp_sabl[email protected]:project1.git");
                content.AppendLine("	fetch = +refs/heads/*:refs/remotes/test/*");
                content.AppendLine("	puttykeyfile = C:/Users/sergiy.pustovit/spustovit_sintez_key_1.ppk");

                //Write test config
                File.WriteAllText(GetConfigFileName(), content.ToString(), Encoding.UTF8);
            }

            //CHECK GET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("0", configFile.GetValue("core.repositoryformatversion"));
            }

            //CHECK SET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                configFile.SetValue("core.repositoryformatversion", "1");
                configFile.Save();
            }

            //CHECK WRITTEN VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("1", configFile.GetValue("core.repositoryformatversion"));
            }
        }
开发者ID:christruman,项目名称:gitextensions,代码行数:52,代码来源:ConfigFileTest.cs

示例10: SetEncoding

 public static void SetEncoding(Encoding e, ConfigFile configFile, string name)
 {
     string value = e == null ? "" : e.HeaderName;
     configFile.SetValue(name, value);
 }
开发者ID:bergerjac,项目名称:gitextensions,代码行数:5,代码来源:CommonLogic.cs

示例11: TestSetValueSectionWithDotNonExisting

        public void TestSetValueSectionWithDotNonExisting()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.SetValue("submodule.test.test2.path1", "submodule.test.test2.path1");
            configFile.SetValue("submodule.test.test2.path2", "submodule.test.test2.path2");
            configFile.Save();

            configFile.SetValue("submodule.test.test1.path1", "submodule.test.test1.path1");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            Assert.AreEqual("submodule.test.test1.path1", configFile.GetValue("submodule.test.test1.path1"));
            Assert.AreEqual("submodule.test.test2.path1", configFile.GetValue("submodule.test.test2.path1"));
            Assert.AreEqual("submodule.test.test2.path2", configFile.GetValue("submodule.test.test2.path2"));
        }
开发者ID:Copro,项目名称:gitextensionstest,代码行数:15,代码来源:ConfigFileTest.cs

示例12: TestSetValueNonExisting

        public void TestSetValueNonExisting()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.Save();

            configFile.SetValue("section1.key1", "section1key1");
            configFile.SetValue("section2.key1", "section2key1");
            configFile.SetValue("section1.key2", "section1key2");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            Assert.AreEqual("section1key1", configFile.GetValue("section1.key1"));
            Assert.AreEqual("section2key1", configFile.GetValue("section2.key1"));
            Assert.AreEqual("section1key2", configFile.GetValue("section1.key2"));
        }
开发者ID:Copro,项目名称:gitextensionstest,代码行数:15,代码来源:ConfigFileTest.cs

示例13: TestSetValueExisting

        public void TestSetValueExisting()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.SetValue("section.key", "section.key");
            configFile.Save();

            configFile.SetValue("section.key", "section.keyoverwrite");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            Assert.AreEqual("section.keyoverwrite", configFile.GetValue("section.key"));
        }
开发者ID:Copro,项目名称:gitextensionstest,代码行数:12,代码来源:ConfigFileTest.cs

示例14: UncPathTest2

        public void UncPathTest2()
        {
            { //TESTDATA
                StringBuilder content = new StringBuilder();

                content.AppendLine(@"[path]");
                content.AppendLine(@"	unc = \\\\test\\"); //<- escaped value in config file

                //Write test config
                File.WriteAllText(GetConfigFileName(), content.ToString(), Encoding.UTF8);
            }

            //CHECK GET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual(@"\\test\", configFile.GetValue("path.unc"));
            }

            //CHECK SET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                configFile.SetValue("path.unc", @"\\test\test2\");
                configFile.Save();
            }

            //CHECK WRITTEN VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual(@"\\test\test2\", configFile.GetValue("path.unc"));
            }
        }
开发者ID:jystic,项目名称:gitextensions,代码行数:31,代码来源:ConfigFileTest.cs

示例15: TestWithSectionWithDot2

        public void TestWithSectionWithDot2()
        {
            { //TESTDATA
                StringBuilder content = new StringBuilder();

                content.AppendLine("[submodule.test.test]");
                content.AppendLine("path = test.test");

                //Write test config
                File.WriteAllText(GetConfigFileName(), content.ToString(), Encoding.UTF8);
            }

            //CHECK GET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("test.test", configFile.GetValue("submodule.test.test.path"));
            }

            //CHECK SET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                configFile.SetValue("submodule.test.test.path", "newvalue");
                configFile.Save();
            }

            //CHECK WRITTEN VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("newvalue", configFile.GetValue("submodule.test.test.path"));
            }
        }
开发者ID:jystic,项目名称:gitextensions,代码行数:31,代码来源:ConfigFileTest.cs


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