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


C# ConfigFile.Save方法代码示例

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


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

示例1: WriteToConfig

 public void WriteToConfig(ConfigFile config)
 {
     Log.ConfigFile.Print("Writing Emulated Device: " + this.name + " to " + config.GetPath());
     config.Set("Emulation.DeviceName", this.name.ToString());
     config.Set("Emulation.OSCategory", this.os.ToString());
     config.Set("Emulation.InputCategory", this.input.ToString());
     config.Set("Emulation.ScreenCategory", this.screen.ToString());
     config.Set("Emulation.ScreenDensityCategory", this.screenDensity.ToString());
     config.Save((string) null);
 }
开发者ID:slb1988,项目名称:StrangeIoCLearning,代码行数:10,代码来源:DevicePreset.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.AddValue("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.AreEqual("origin1", configFile.GetValue(remote), remote);

                remote = "branch \"branchName1\".remote";
                Assert.AreNotEqual("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:Nehle,项目名称:gitextensions,代码行数:39,代码来源:ConfigFileTest.cs

示例4: CanSaveMultipleValuesForSameKeyInSections

        public void CanSaveMultipleValuesForSameKeyInSections()
        {
            // create test data
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());

                configFile.AddValue("remote.origin.fetch", "+mypath");
                configFile.AddValue("remote.origin.fetch", "+myotherpath");

                configFile.Save();
            }

            // verify
            {

                ConfigFile configFile = new ConfigFile(GetConfigFileName());

                IList<string> values = configFile.GetValues("remote.origin.fetch");

                Assert.IsTrue(values.SingleOrDefault(x => x == "+mypath") != null);
                Assert.IsTrue(values.SingleOrDefault(x => x == "+myotherpath") != null);
            }
        }
开发者ID:christruman,项目名称:gitextensions,代码行数:23,代码来源:ConfigFileTest.cs

示例5: RemoveSubmoduleClick

        private void RemoveSubmoduleClick(object sender, EventArgs e)
        {
            if (Submodules.SelectedRows.Count != 1 ||
                MessageBox.Show(this, _removeSelectedSubmodule.Text, _removeSelectedSubmoduleCaption.Text, MessageBoxButtons.YesNo) !=
                DialogResult.Yes)
                return;

            Cursor.Current = Cursors.WaitCursor;
            Settings.Module.RunGitCmd("rm --cached \"" + SubModuleName.Text + "\"");

            var modules = new ConfigFile(Settings.WorkingDir + ".gitmodules");
            modules.RemoveConfigSection("submodule \"" + SubModuleName.Text + "\"");
            if (modules.GetConfigSections().Count > 0)
                modules.Save();
            else
                Settings.Module.RunGitCmd("rm --cached \".gitmodules\"");

            var configFile = Settings.Module.GetLocalConfig();
            configFile.RemoveConfigSection("submodule \"" + SubModuleName.Text + "\"");
            configFile.Save();

            Initialize();
            Cursor.Current = Cursors.Default;
        }
开发者ID:christruman,项目名称:gitextensions,代码行数:24,代码来源:FormSubmodules.cs

示例6: 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.GetPathValue("path.unc"));
            }

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

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

示例7: 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

示例8: TestNonExistingFile

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

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

示例9: SpacesInSubSectionTest

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

                content.AppendLine("[section \"sub section\"]");
                content.AppendLine("	test = test");

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

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

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

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

示例10: RandomTestCase1

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

                content.AppendLine("[merge]");
                content.AppendLine("	tool = kdiff3");
                content.AppendLine("[mergetool \"kdiff3\"]");
                content.AppendLine("	path = c:/Program Files (x86)/KDiff3/kdiff3.exe");
                content.AppendLine("[user]");
                content.AppendLine("	name = Sergey Pustovit");
                content.AppendLine("	email = [email protected]");
                content.AppendLine("[core]");
                content.AppendLine("	safecrlf = false");
                content.AppendLine("	editor = C:/Program Files (x86)/Notepad++/notepad++.exe");
                content.AppendLine("[diff]");
                content.AppendLine("	tool = kdiff3");
                content.AppendLine("[difftool \"kdiff3\"]");
                content.AppendLine("	path = c:/Program Files (x86)/KDiff3/kdiff3.exe");

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

            //CHECK GET CONFIG VALUE
            {
                ConfigFile configFile = new ConfigFile(GetConfigFileName());
                Assert.AreEqual("Sergey Pustovit", configFile.GetValue("user.name"));
            }

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

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

示例11: TestSetValueSectionWithDotExisting

        public void TestSetValueSectionWithDotExisting()
        {
            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.SetValue("submodule.test.test1.path1", "submodule.test.test1.path1");
            configFile.Save();

            configFile = new ConfigFile(GetConfigFileName(), true);
            CheckValueIsEqual(configFile, "submodule.test.test1.path1", "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

示例12: 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);
            CheckValueIsEqual(configFile, "section.key", "section.keyoverwrite");
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:12,代码来源:ConfigFileTest.cs

示例13: 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);
            CheckValueIsEqual(configFile, "section1.key1", "section1key1");
            CheckValueIsEqual(configFile, "section2.key1", "section2key1");
            CheckValueIsEqual(configFile, "section1.key2", "section1key2");
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:15,代码来源:ConfigFileTest.cs

示例14: TestSave

        public void TestSave()
        {
            ConfigFile configFile = new ConfigFile(GetConfigFileName(), true);
            configFile.SetValue("branch.BranchName1.remote", "origin1");
            configFile.Save();

            byte[] expectedFileContent =
                GitModule.SystemEncoding.GetBytes(
                    String.Format("[branch \"BranchName1\"]{0}\tremote = origin1{0}", Environment.NewLine));

            Assert.IsTrue(File.Exists(GetConfigFileName()));
            byte[] fileContent = File.ReadAllBytes(GetConfigFileName());

            Assert.AreEqual(expectedFileContent.Length, fileContent.Length);
            for (int index = 0; index < fileContent.Length; index++)
            {
                Assert.AreEqual(expectedFileContent[index], fileContent[index]);
            }
        }
开发者ID:Carbenium,项目名称:gitextensions,代码行数:19,代码来源:ConfigFileTest.cs

示例15: button3_Click

        // psw setzen
        private void button3_Click(object sender, System.EventArgs e)
        {
            if (this.checkPsw() &&
                this.textBox2.Text == this.textBox3.Text &&
                this.textBox2.Text != "")
            {
                ConfigFile configFile = new ConfigFile(Util.CONFIGPATH);
                configFile["pw"] = this.textBox2.Text;
                configFile.Save(Util.CONFIGPATH);

                this.Height = 104;
                this.button1.Enabled = true;
                this.textBox1.Text = "";
                this.textBox1.Select();
            }
            else
            {
                Util.MBoxError("Angaben nicht korrekt!\n" +
                    "Geben Sie bitte das alte und das neue Passwort\nan und bestätigen Sie das neue!");
            }
        }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:22,代码来源:Pswd.cs


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