Split Geekbot.net into src/Bot, src/Core, and src/Web
This commit is contained in:
parent
7b6dd2d2f9
commit
fc0af492ad
197 changed files with 542 additions and 498 deletions
9
src/Core/KvInMemoryStore/IKvInMemoryStore.cs
Normal file
9
src/Core/KvInMemoryStore/IKvInMemoryStore.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Geekbot.Core.KvInMemoryStore
|
||||
{
|
||||
public interface IKvInMemoryStore
|
||||
{
|
||||
public T Get<T>(string key);
|
||||
public void Set<T>(string key, T value);
|
||||
public void Remove(string key);
|
||||
}
|
||||
}
|
32
src/Core/KvInMemoryStore/KvInMemoryStore.cs
Normal file
32
src/Core/KvInMemoryStore/KvInMemoryStore.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Geekbot.Core.KvInMemoryStore
|
||||
{
|
||||
public class KvInInMemoryStore : IKvInMemoryStore
|
||||
{
|
||||
private readonly Dictionary<string, object> _storage = new Dictionary<string, object>();
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) _storage[key];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public void Set<T>(string key, T value)
|
||||
{
|
||||
_storage.Remove(key);
|
||||
_storage.Add(key, value);
|
||||
}
|
||||
|
||||
public void Remove(string key)
|
||||
{
|
||||
_storage.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue