using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Web;
///
/// Config 的摘要说明
///
public static class Config
{
private static bool noCache = true;
private static JObject BuildItems()
{
var json = File.ReadAllText(HttpContext.Current.Server.MapPath("config.json"));
return JObject.Parse(json);
}
public static JObject Items
{
get
{
if (noCache || _Items == null)
{
_Items = BuildItems();
}
return _Items;
}
}
private static JObject _Items;
public static T GetValue(string key)
{
return Items[key].Value();
}
public static String[] GetStringList(string key)
{
return Items[key].Select(x => x.Value()).ToArray();
}
public static String GetString(string key)
{
return GetValue(key);
}
public static int GetInt(string key)
{
return GetValue(key);
}
}