Пример #1
0
        public void SaveEntries(IEnumerable <Credential> entries)
        {
            CredentialsWrapper credentials = new CredentialsWrapper()
            {
                Credentials = entries.ToList()
            };
            string serializedCreds = JsonConvert.SerializeObject(credentials, Constants.JsonSerializerSettings);

            lock (lockObject)
            {
                WriteToFile(this.fileName, serializedCreds);
            }
        }
Пример #2
0
        public IEnumerable <Credential> LoadEntries()
        {
            if (!File.Exists(this.fileName))
            {
                return(Enumerable.Empty <Credential>());
            }

            string serializedCreds;

            lock (lockObject)
            {
                serializedCreds = File.ReadAllText(this.fileName);
            }

            CredentialsWrapper creds = JsonConvert.DeserializeObject <CredentialsWrapper>(serializedCreds, Constants.JsonSerializerSettings);

            if (creds != null)
            {
                return(creds.Credentials);
            }
            return(Enumerable.Empty <Credential>());
        }