???????????????????????????????CRUD??????
???????????????:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfigManager
{
class Program
{
static void Main(string[] args)
{
var settings = ConfigManager.Appettings;
foreach(var item in settings)
{
Console.WriteLine("key:{0}??value:{1}"??item.Key??item.Value);
}
var t1 = ConfigManager.Appettings["key1"];
//test add
ConfigManager.Add("t"??"test");
//var t2 = ConfigManager.Appettings;
//update
ConfigManager.Update("t"??"test123");
//remove
ConfigManager.Remove("t");
Console.ReadKey();
}
}
}

??????????????С?
?????????????????!????????????
????//test not item in Dictionary
????var t2 = ConfigManager.Appettings["luckyhu"];
??????????????????!
???????????????????????????????????????????????????????.???????????????????????????.
?????????????????.
public class SettingManager : Dictionary<string?? string>
{
private static SettingManager _Settings = null;
public static SettingManager Settings
{
get
{
if (_Settings == null)
_Settings = new SettingManager();
return _Settings;
}
}
private SettingManager()
{
//Init Data
//DataSoure:truely data here...
for (int i = 0; i < 10; i++)
{
var key = String.Format("key{0}"?? i);
var value = String.Format("value{0}"?? i);
if (!this.Keys.Contains(key))
this.Add(key?? value);
}
}
public string this[string key]
{
get
{
if (!this.ContainsKey(key))
return String.Empty;
return base[key];
}
set
{
base[key] = value;
}
}
public static bool GetBoolValue(string key)
{
bool value = false;
bool.TryParse(Settings[key]?? out value);
return value;
}
public static int GetIntValue(string key)
{
int value = 0;
int.TryParse(Settings[key]?? out value);
return value;
}
}
????????????????????????????????:
????1.?????????
????2.????????????????????
????3.???????????Dictionary????????????CRUD
????4.??????????????????????
???????????Щ???????????????????.
?????e???????????????

????????????OK??
???????????????????????ù??????????? ????и???????????????????????????????????? .