Esempio n. 1
0
        public void AppConfigWriteTest()
        {
            UserConfigWriter.m_TestUserConfigName = Path.GetTempPath() + "user_v6.config";
            AppConfigWriter.m_TestAppConfigName   = Path.GetTempPath() + "app_v6.config";
            if (File.Exists(AppConfigWriter.m_TestAppConfigName))
            {
                File.Delete(AppConfigWriter.m_TestAppConfigName);
            }
            var config = new ConfigWriter();

            config.Read(AppConfigWriter.m_TestAppConfigName);
            Assert.AreEqual("", config.GetItem("DocumentPrinter"));
            string expected = "test printer";
            //Assert.AreEqual(AppConfigWriter.Instance.FileName, AppConfigWriter.m_TestAppConfigName);
            //AppConfigWriter.Instance.SetItem("DocumentPrinter", expected);
            //AppConfigWriter.Instance.SetItem("SomeItem", "true");
            //AppConfigWriter.Instance.Save();
            //config.Read(AppConfigWriter.m_TestAppConfigName);
            //Assert.AreEqual(expected, config.GetItem("DocumentPrinter"));
            //Assert.AreEqual("", config.GetItem("SomeItem"));
            ConfigWriter target = AppConfigWriter.CreateConfigWriter();

            target.SetItem("DocumentPrinter", expected);
            target.SetItem("SomeItem", "false");
            target.Save();
            config.Read(AppConfigWriter.m_TestAppConfigName);
            Assert.AreEqual(expected, config.GetItem("DocumentPrinter"));
            Assert.AreEqual("", config.GetItem("SomeItem"));
        }
Esempio n. 2
0
 private void SaveArchiveConnection()
 {
     if (!chkAllowArchiveConnection.Checked)
     {
         txtArchiveServer.Text   = "";
         txtArchiveDatabase.Text = "";
         txtArchiveUser.Text     = "";
         txtArchivePassword.Text = "";
         m_config.SetItem(ArchiveDatabase, "");
         m_config.SetItem(ArchiveServer, "");
         m_config.SetItem(ArchiveUser, "");
         m_config.SetItem(ArchivePassword, "");
     }
     else
     {
         m_config.SetItem(ArchiveDatabase, txtArchiveDatabase.Text);
         m_config.SetItem(ArchiveServer, txtArchiveServer.Text);
         m_config.SetItem(ArchiveUser, Cryptor.Encrypt(txtArchiveUser.Text));
         m_config.SetItem(ArchivePassword, Cryptor.Encrypt(txtArchivePassword.Text, txtArchiveUser.Text));
     }
 }