Compare commits
No commits in common. "master" and "v0.1" have entirely different histories.
@ -6,9 +6,5 @@ public interface IStore<T> : IDisposable
|
|||||||
|
|
||||||
public bool Add(T item);
|
public bool Add(T item);
|
||||||
|
|
||||||
public bool Has(T item);
|
|
||||||
|
|
||||||
public bool Remove(T item);
|
|
||||||
|
|
||||||
public IEnumerable<T> GetValues();
|
public IEnumerable<T> GetValues();
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,6 @@ public class LocalStore<T> : IStore<T>
|
|||||||
using (FileStream fs = new FileStream(this.filePath, FileMode.OpenOrCreate))
|
using (FileStream fs = new FileStream(this.filePath, FileMode.OpenOrCreate))
|
||||||
using (StreamWriter writer = new StreamWriter(fs, DefaultEncoding))
|
using (StreamWriter writer = new StreamWriter(fs, DefaultEncoding))
|
||||||
{
|
{
|
||||||
fs.Seek(0, SeekOrigin.Begin);
|
|
||||||
fs.SetLength(0);
|
|
||||||
|
|
||||||
foreach (T item in this.items)
|
foreach (T item in this.items)
|
||||||
{
|
{
|
||||||
string json = JsonSerializer.Serialize<T>(item);
|
string json = JsonSerializer.Serialize<T>(item);
|
||||||
@ -56,16 +53,6 @@ public class LocalStore<T> : IStore<T>
|
|||||||
return true;
|
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()
|
public IEnumerable<T> GetValues()
|
||||||
{
|
{
|
||||||
return this.items.ToList();
|
return this.items.ToList();
|
||||||
|
10
JsonDB.cs
10
JsonDB.cs
@ -26,16 +26,6 @@ public class JsonDB<T> : IDisposable
|
|||||||
return this.store.Add(item);
|
return this.store.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Has(T item)
|
|
||||||
{
|
|
||||||
return this.store.Has(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(T item)
|
|
||||||
{
|
|
||||||
return this.store.Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T> GetValues()
|
public IEnumerable<T> GetValues()
|
||||||
{
|
{
|
||||||
return this.store.GetValues();
|
return this.store.GetValues();
|
||||||
|
@ -20,7 +20,7 @@ bool result = jsonDB.Add(new T());
|
|||||||
IEnumerable<T> allItems = jsonDB.GetValues();
|
IEnumerable<T> allItems = jsonDB.GetValues();
|
||||||
|
|
||||||
// DBから特定のアイテムを取得します。
|
// DBから特定のアイテムを取得します。
|
||||||
IEnumerable<T> filteredItems = jsonDB.GetValues((T) => true);
|
IEnumerable<T> filteredItems = jsonDB.GetValues((T) => true):
|
||||||
|
|
||||||
// ファイルに書き込む
|
// ファイルに書き込む
|
||||||
jsonDB.Commit();
|
jsonDB.Commit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user