public void Add(IPersonAuthInfo personAuthInfo) { lock (_charactersLock) { var wrapper = new CharactersWrapper { Person = (PersonAuthInfo)personAuthInfo }; var wrappers = LoadCharacters().Add(wrapper); Save(wrappers); lock (_sessionsLock) { var sWrapper = new SessionsWrapper { PersonId = personAuthInfo.PersonId }; var sWrappers = LoadSessions().Add(sWrapper); Save(sWrappers); } } }
private void Save(CharactersWrapper[] wrappers) { var data = JsonUtils.Serialize(wrappers); using (var file = new FileStream(Path.Combine(_folder, "Characters.json"), FileMode.Create, FileAccess.Write, FileShare.None)) using (var writer = new StreamWriter(file)) writer.Write(data); }