public void Write(IAmeSession session, Stream stream) { // TODO open dialog asking user to save the map files before closing AmeSessionJson json = new AmeSessionJson(session); JsonSerializer serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.NullValueHandling = NullValueHandling.Ignore; using (StreamWriter streamWriter = new StreamWriter(stream)) using (JsonWriter jsonWriter = new JsonTextWriter(streamWriter)) { serializer.Serialize(jsonWriter, json); } }
public IAmeSession Read(string file) { AmeSessionJson json = JsonConvert.DeserializeObject <AmeSessionJson>(File.ReadAllText(file)); return(json.Generate()); }