-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordDatabase.cs
More file actions
46 lines (42 loc) · 1.18 KB
/
PasswordDatabase.cs
File metadata and controls
46 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections.Generic;
namespace AuthMe
{
public class PasswordDatabase
{
private DataStorage<List<Passwords>> DataStorage { get; set; }
public List<Passwords> Data { get; private set; }
public PasswordDatabase()
{
DataStorage = new DataStorage<List<Passwords>>(MQSPlugin.Instance.Directory, "Passwords.json");
}
public void Reload()
{
Data = DataStorage.Read();
if (Data == null)
{
Data = new List<Passwords>();
DataStorage.Save(Data);
}
}
public void AddPassword(Passwords password)
{
Data.Add(password);
DataStorage.Save(Data);
}
public bool RemovePassword(string name)
{
var flag = Data.RemoveAll(x => x.Name.Equals(name));
if (flag > 0)
{
DataStorage.Save(Data);
return true;
}
return false;
}
public void RemoveAll()
{
Data.Clear();
DataStorage.Save(Data);
}
}
}