示例#1
0
        public static DyConfig GetConfig()
        {
            if (!File.Exists(filename))
            {
                dyConfig = new DyConfig();
                Save();
                return(dyConfig);
            }

            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

            byte[] buf = new byte[fs.Length];
            fs.Read(buf, 0, buf.Length);
            fs.Close();
            string jsonString = Encoding.UTF8.GetString(buf).Replace("\r", "").Replace("\n", "");

            try
            {
                JObject json = JObject.Parse(jsonString);
                dyConfig = (DyConfig)json.ToObject(typeof(DyConfig));
                return(dyConfig);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
 public static void Save(DyConfig config)
 {
     dyConfig = config;
     Save();
 }