Beispiel #1
0
 public void LoadTraderStateFromDisk()
 {
     using (StreamReader reader = new StreamReader(File.OpenRead(TraderStateFilePath)))
     {
         string           jsonString = reader.ReadToEnd();
         TraderStateArray stateArray = JsonUtility.FromJson <TraderStateArray>(jsonString);
         traderStates = stateArray.array;
     }
 }
Beispiel #2
0
        public void UpdateTraderStateOnDisk()
        {
            TraderStateArray stateArray = new TraderStateArray(traderStates);

            using (StreamWriter writer = new StreamWriter(File.OpenWrite(TraderStateFilePath)))
            {
                string jsonData  = JsonUtility.ToJson(stateArray, true);
                char[] charArray = jsonData.ToCharArray();
                writer.Write(charArray);
                writer.Flush();
                writer.BaseStream.SetLength(writer.BaseStream.Position);
            }
        }