2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

AutoReconnect

This commit is contained in:
2022-08-11 21:28:16 +03:00
parent af94ce318a
commit 21a2061fc4
12 changed files with 355 additions and 154 deletions

View File

@ -27,17 +27,30 @@ public class MemoryStore : IStore
public string Link(IResource resource)
{
if (resource.Instance.Store == this)
return this.Instance.Name + "/" + resource.Instance.Id;
return this.Instance.Name + "/$" + resource.Instance.Id;
return null;
}
public AsyncReply<IResource> Get(string path)
{
foreach (var r in resources)
if (r.Value.Instance.Name == path)
return new AsyncReply<IResource>(r.Value);
if (path.StartsWith("$"))
{
uint id;
if (uint.TryParse(path.Substring(1), out id))
{
foreach (var r in resources)
if (r.Value.Instance.Id == id)
return new AsyncReply<IResource>(r.Value);
}
}
else
{
foreach (var r in resources)
if (r.Value.Instance.Name == path)
return new AsyncReply<IResource>(r.Value);
}
return new AsyncReply<IResource>(null);
}