110,535
社区成员
发帖
与我相关
我的任务
分享
public class PriorityDic
{
private static PairedBase _paired = new PriorityPaired();
public static string GetValue(string key)
{
return _paired.GetValue(key);
}
public static string GetKey(string value)
{
return _paired.GetKey(value);
}
public static bool ContainsKey(string key)
{
return _paired.ContainsKey(key);
}
public static bool ContainsValue(string value)
{
return _paired.ContainsValue(value);
}
}
public class RefreshStateDic
{
private static PairedBase _paired = new RefreshStatePaired();
public static string GetValue(string key)
{
return _paired.GetValue(key);
}
public static string GetKey(string value)
{
return _paired.GetKey(value);
}
public static bool ContainsKey(string key)
{
return _paired.ContainsKey(key);
}
public static bool ContainsValue(string value)
{
return _paired.ContainsValue(value);
}
}
public class Dic<T> where T : PairedBase, new()
{
private static PairedBase _paired = new T();
public static string GetValue(string key)
{
return _paired.GetValue(key);
}
public static string GetKey(string value)
{
return _paired.GetKey(value);
}
public static bool ContainsKey(string key)
{
return _paired.ContainsKey(key);
}
public static bool ContainsValue(string value)
{
return _paired.ContainsValue(value);
}
}
public abstract class PairedBase
{
protected Dictionary<string, string> _dictionary = new Dictionary<string, string>();
protected PairedBase()
{
Initialize();
}
protected abstract void Initialize();
public string GetValue(string key)
{
return _dictionary.ContainsKey(key) ? _dictionary[key] : string.Empty;
}
public string GetKey(string value)
{
if (!_dictionary.ContainsValue(value))
return string.Empty;
var item = _dictionary.Where(c => c.Value == value);
return item.Count() > 0 ? item.FirstOrDefault().Key : string.Empty;
}
public bool ContainsKey(string key)
{
return _dictionary.ContainsKey(key);
}
public bool ContainsValue(string value)
{
return _dictionary.ContainsValue(value);
}
}
public class PriorityPaired : PairedBase
{
protected override void Initialize()
{
_dictionary.Add("高", "1");
_dictionary.Add("中", "2");
_dictionary.Add("低", "3");
}
}
public class RefreshStatePaired : PairedBase
{
protected override void Initialize()
{
_dictionary.Add("发生更新", "1");
_dictionary.Add("正则表达式失效", "2");
_dictionary.Add("网站响应超时", "3");
_dictionary.Add("网站出现异常", "4");
_dictionary.Add("数据库信息有误", "5");
}
}
public class PriorityDic
{
private static PairedBase _paired = new PriorityPaired();
public static string GetValue(string key)
{
return _paired.GetValue(key);
}
public static string GetKey(string value)
{
return _paired.GetKey(value);
}
public static bool ContainsKey(string key)
{
return _paired.ContainsKey(key);
}
public static bool ContainsValue(string value)
{
return _paired.ContainsValue(value);
}
}
public class RefreshStateDic
{
private static PairedBase _paired = new RefreshStatePaired();
public static string GetValue(string key)
{
return _paired.GetValue(key);
}
public static string GetKey(string value)
{
return _paired.GetKey(value);
}
public static bool ContainsKey(string key)
{
return _paired.ContainsKey(key);
}
public static bool ContainsValue(string value)
{
return _paired.ContainsValue(value);
}
}