예제 #1
0
        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);
                }
            }
        }
예제 #2
0
 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);
 }