Compare commits
3 Commits
883236e581
...
0e7a40a639
Author | SHA1 | Date | |
---|---|---|---|
0e7a40a639 | |||
d9e3e7bf3b | |||
c8c152ae68 |
@ -6,5 +6,9 @@ public interface IStore<T> : IDisposable
|
||||
|
||||
public bool Add(T item);
|
||||
|
||||
public bool Has(T item);
|
||||
|
||||
public bool Remove(T item);
|
||||
|
||||
public IEnumerable<T> GetValues();
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ public class LocalStore<T> : IStore<T>
|
||||
using (FileStream fs = new FileStream(this.filePath, FileMode.OpenOrCreate))
|
||||
using (StreamWriter writer = new StreamWriter(fs, DefaultEncoding))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
fs.SetLength(0);
|
||||
|
||||
foreach (T item in this.items)
|
||||
{
|
||||
string json = JsonSerializer.Serialize<T>(item);
|
||||
@ -53,6 +56,16 @@ public class LocalStore<T> : IStore<T>
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Has(T item)
|
||||
{
|
||||
return this.items.Contains(item);
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
return this.items.Remove(item);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetValues()
|
||||
{
|
||||
return this.items.ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user