mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 13:33:13 +00:00
Add project files.
This commit is contained in:
56
Esiur/Stores/MemoryStore.cs
Normal file
56
Esiur/Stores/MemoryStore.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Esiur.Engine;
|
||||
|
||||
namespace Esiur.Stores
|
||||
{
|
||||
public class MemoryStore : IStore
|
||||
{
|
||||
public Instance Instance { get; set; }
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
Dictionary<uint, IResource> resources = new Dictionary<uint, IResource>();
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Link(IResource resource)
|
||||
{
|
||||
if (resource.Instance.Store == this)
|
||||
return this.Instance.Name + "/" + resource.Instance.Id;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Get(string path)
|
||||
{
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public bool Put(IResource resource)
|
||||
{
|
||||
resources.Add(resource.Instance.Id, resource);
|
||||
return true;
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Retrieve(uint iid)
|
||||
{
|
||||
if (resources.ContainsKey(iid))
|
||||
return new AsyncReply<IResource>(resources[iid]);
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user