From 54823b0b2be8f7f3dc97170781bf9646cac0bcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Mon, 21 Dec 2020 02:29:54 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=B7=BB=E5=8A=A0=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E5=8D=95=E6=AC=A1=E8=AF=BB=E5=8F=96ini=E9=94=AE=E5=80=BC?= =?UTF-8?q?=E6=96=B9=E6=B3=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 206fcfb759b4a658dfd15319436a56c74af28ecd. --- ContextMenuManager/AppConfig.cs | 11 +++++----- .../BulePointLilac.Methods/IniWriter.cs | 21 +------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/ContextMenuManager/AppConfig.cs b/ContextMenuManager/AppConfig.cs index 063a3e0..682858a 100644 --- a/ContextMenuManager/AppConfig.cs +++ b/ContextMenuManager/AppConfig.cs @@ -50,6 +50,7 @@ namespace ContextMenuManager "https://www.so.com/s?q=%s", //360搜索 }; + private static IniReader ConfigReader => new IniReader(ConfigIni); private static IniWriter ConfigWriter => new IniWriter(ConfigIni); public static DateTime LastCheckUpdateTime @@ -58,7 +59,7 @@ namespace ContextMenuManager { try { - string time = ConfigWriter.GetValue("General", "LastCheckUpdateTime"); + string time = ConfigReader.GetValue("General", "LastCheckUpdateTime"); //二进制数据时间不会受系统时间格式影响 return DateTime.FromBinary(Convert.ToInt64(time)); } @@ -78,7 +79,7 @@ namespace ContextMenuManager { get { - string language = ConfigWriter.GetValue("General", "Language"); + string language = ConfigReader.GetValue("General", "Language"); DirectoryInfo di = new DirectoryInfo(LangsDir); if(language == string.Empty && di.Exists) { @@ -104,13 +105,13 @@ namespace ContextMenuManager public static bool AutoBackup { - get => ConfigWriter.GetValue("General", "AutoBackup") != "0"; + get => ConfigReader.GetValue("General", "AutoBackup") != "0"; set => ConfigWriter.SetValue("General", "AutoBackup", (value ? 1 : 0).ToString()); } public static bool ProtectOpenItem { - get => ConfigWriter.GetValue("General", "ProtectOpenItem") != "0"; + get => ConfigReader.GetValue("General", "ProtectOpenItem") != "0"; set => ConfigWriter.SetValue("General", "ProtectOpenItem", (value ? 1 : 0).ToString()); } @@ -118,7 +119,7 @@ namespace ContextMenuManager { get { - string url = ConfigWriter.GetValue("General", "EngineUrl"); + string url = ConfigReader.GetValue("General", "EngineUrl"); if(url.IsNullOrWhiteSpace()) url = EngineUrls[0]; return url; } diff --git a/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs b/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs index c7e0692..5c9c888 100644 --- a/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs +++ b/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs @@ -33,8 +33,7 @@ namespace BulePointLilac.Methods return lines; } - /// 是否是获取value值 - private void SetValue(string section, string key, ref string value, bool isGetValue) + public void SetValue(string section, string key, string value) { if(section == null) return; List lines = GetLines(); @@ -68,11 +67,6 @@ namespace BulePointLilac.Methods string str = lines[i].Substring(0, index).TrimEnd(); if(str.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if(isGetValue)//如果是获取Value值,直接返回 - { - value = lines[i].Substring(index + 1).Trim(); - return; - } keyRow = i; continue;//得到目标key行 } } @@ -143,19 +137,6 @@ namespace BulePointLilac.Methods } } - public void SetValue(string section, string key, string value) - { - SetValue(section, key, ref value, false); - } - - /// 一次读取只获取一个值,用此方法比IniReader.GetValue要快 - public string GetValue(string section, string key) - { - string value = string.Empty; - SetValue(section, key, ref value, true); - return value; - } - public void DeleteKey(string section, string key) { SetValue(section, key, null);