Exemplo n.º 1
0
 protected void SaveJson()
 {
     try
     {
         if (!string.IsNullOrEmpty(m_pJsonPath))
         {
             VirtualSerializer Json = new VirtualSerializer();
             string            json = Json.GetJSON(this);
             var fs = new FileStream(m_pJsonPath, FileMode.Create, FileAccess.Write);
             var sw = new StreamWriter(fs);
             sw.BaseStream.Seek(0, SeekOrigin.End);
             sw.WriteLine(json);
             sw.Flush();
             sw.Close();
             fs.Close();
         }
     }
     catch { }
 }
Exemplo n.º 2
0
 protected void ReadJson()
 {
     try
     {
         if (File.Exists(m_pJsonPath))
         {
             var          fs   = new FileStream(m_pJsonPath, FileMode.Open, FileAccess.Read);
             StreamReader sr   = new StreamReader(fs);
             string       json = sr.ReadToEnd();
             fs.Close();
             JavaScriptSerializer js          = new JavaScriptSerializer();
             VirtualSerializer    virtualJson = js.Deserialize <VirtualSerializer>(json);
             BreakOpenTime  = virtualJson.BreakOpenTime;
             BreakOpenValue = virtualJson.BreakOpenValue;
             LiftSpeedTime  = virtualJson.LiftSpeedTime;
             LiftSpeedValue = virtualJson.LiftSpeedValue;
             PatrolTime     = virtualJson.PatrolTime;
             PatrolValue    = virtualJson.PatrolValue;
             sr.Close();
         }
     }
     catch { }
 }