mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
.Net 6 Upgrade
This commit is contained in:
@ -8,140 +8,139 @@ using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Resource.Template;
|
||||
|
||||
namespace Esiur.Stores
|
||||
namespace Esiur.Stores;
|
||||
|
||||
public class MemoryStore : IStore
|
||||
{
|
||||
public class MemoryStore : IStore
|
||||
public Instance Instance { get; set; }
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
KeyList<uint, IResource> resources = new KeyList<uint, IResource>();
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
public Instance Instance { get; set; }
|
||||
OnDestroy?.Invoke(this);
|
||||
}
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
public string Link(IResource resource)
|
||||
{
|
||||
if (resource.Instance.Store == this)
|
||||
return this.Instance.Name + "/" + resource.Instance.Id;
|
||||
|
||||
KeyList<uint, IResource> resources = new KeyList<uint, IResource>();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
public AsyncReply<IResource> Get(string path)
|
||||
{
|
||||
foreach (var r in resources)
|
||||
if (r.Value.Instance.Name == path)
|
||||
return new AsyncReply<IResource>(r.Value);
|
||||
|
||||
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Put(IResource resource)
|
||||
{
|
||||
|
||||
resources.Add(resource.Instance.Id, resource);// new WeakReference<IResource>(resource));
|
||||
resource.Instance.Variables["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
resource.Instance.Variables["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Retrieve(uint iid)
|
||||
{
|
||||
if (resources.ContainsKey(iid))
|
||||
{
|
||||
OnDestroy?.Invoke(this);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
foreach (var r in resources)
|
||||
if (r.Value.Instance.Name == path)
|
||||
return new AsyncReply<IResource>(r.Value);
|
||||
|
||||
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Put(IResource resource)
|
||||
{
|
||||
|
||||
resources.Add(resource.Instance.Id, resource);// new WeakReference<IResource>(resource));
|
||||
resource.Instance.Variables["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
resource.Instance.Variables["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Retrieve(uint iid)
|
||||
{
|
||||
if (resources.ContainsKey(iid))
|
||||
{
|
||||
if (resources.ContainsKey(iid))// .TryGetTarget(out r))
|
||||
return new AsyncReply<IResource>(resources[iid]);
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
if (resources.ContainsKey(iid))// .TryGetTarget(out r))
|
||||
return new AsyncReply<IResource>(resources[iid]);
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Remove(IResource resource)
|
||||
{
|
||||
resources.Remove(resource.Instance.Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public AsyncReply<bool> AddChild(IResource parent, IResource child)
|
||||
{
|
||||
if (parent.Instance.Store == this)
|
||||
{
|
||||
(parent.Instance.Variables["children"] as AutoList<IResource, Instance>).Add(child);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<bool>(false);
|
||||
}
|
||||
|
||||
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
public AsyncReply<bool> RemoveChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<bool> AddParent(IResource resource, IResource parent)
|
||||
{
|
||||
|
||||
if (resource.Instance.Store == this)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
(resource.Instance.Variables["parents"] as AutoList<IResource, Instance>).Add(parent);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<bool>(false);
|
||||
}
|
||||
|
||||
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<bool> RemoveParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Remove(IResource resource)
|
||||
{
|
||||
resources.Remove(resource.Instance.Id);
|
||||
return true;
|
||||
}
|
||||
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var children = (resource.Instance.Variables["children"] as AutoList<IResource, Instance>);
|
||||
|
||||
public bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (name == null)
|
||||
return new AsyncBag<T>(children.Where(x => x is T).Select(x => (T)x).ToArray());
|
||||
else
|
||||
return new AsyncBag<T>(children.Where(x => x is T && x.Instance.Name == name).Select(x => (T)x).ToArray());
|
||||
|
||||
public AsyncReply<bool> AddChild(IResource parent, IResource child)
|
||||
{
|
||||
if (parent.Instance.Store == this)
|
||||
{
|
||||
(parent.Instance.Variables["children"] as AutoList<IResource, Instance>).Add(child);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<bool>(false);
|
||||
}
|
||||
}
|
||||
|
||||
public AsyncReply<bool> RemoveChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var parents = (resource.Instance.Variables["parents"] as AutoList<IResource, Instance>);
|
||||
|
||||
public AsyncReply<bool> AddParent(IResource resource, IResource parent)
|
||||
{
|
||||
|
||||
if (resource.Instance.Store == this)
|
||||
{
|
||||
(resource.Instance.Variables["parents"] as AutoList<IResource, Instance>).Add(parent);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<bool>(false);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> RemoveParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var children = (resource.Instance.Variables["children"] as AutoList<IResource, Instance>);
|
||||
|
||||
if (name == null)
|
||||
return new AsyncBag<T>(children.Where(x=>x is T).Select(x=>(T)x).ToArray());
|
||||
else
|
||||
return new AsyncBag<T>(children.Where(x => x is T && x.Instance.Name == name).Select(x => (T)x).ToArray());
|
||||
|
||||
}
|
||||
|
||||
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var parents = (resource.Instance.Variables["parents"] as AutoList<IResource, Instance>);
|
||||
|
||||
if (name == null)
|
||||
return new AsyncBag<T>(parents.Where(x => x is T).Select(x => (T)x).ToArray());
|
||||
else
|
||||
return new AsyncBag<T>(parents.Where(x => x is T && x.Instance.Name == name).Select(x => (T)x).ToArray());
|
||||
}
|
||||
if (name == null)
|
||||
return new AsyncBag<T>(parents.Where(x => x is T).Select(x => (T)x).ToArray());
|
||||
else
|
||||
return new AsyncBag<T>(parents.Where(x => x is T && x.Instance.Name == name).Select(x => (T)x).ToArray());
|
||||
}
|
||||
}
|
||||
|
@ -8,112 +8,110 @@ using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Resource.Template;
|
||||
|
||||
namespace Esiur.Stores
|
||||
namespace Esiur.Stores;
|
||||
public class TemporaryStore : IStore
|
||||
{
|
||||
public class TemporaryStore : IStore
|
||||
public Instance Instance { get; set; }
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
Dictionary<uint, WeakReference> resources = new Dictionary<uint, WeakReference>();
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
public Instance Instance { get; set; }
|
||||
OnDestroy?.Invoke(this);
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
}
|
||||
|
||||
Dictionary<uint, WeakReference> resources = new Dictionary<uint, WeakReference>();
|
||||
public string Link(IResource resource)
|
||||
{
|
||||
if (resource.Instance.Store == this)
|
||||
return this.Instance.Name + "/" + resource.Instance.Id;
|
||||
|
||||
public void Destroy()
|
||||
return null;
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Get(string path)
|
||||
{
|
||||
foreach (var r in resources)
|
||||
if (r.Value.IsAlive && (r.Value.Target as IResource).Instance.Name == path)
|
||||
return new AsyncReply<IResource>(r.Value.Target as IResource);
|
||||
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Put(IResource resource)
|
||||
{
|
||||
resources.Add(resource.Instance.Id, new WeakReference(resource));// new WeakReference<IResource>(resource));
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Retrieve(uint iid)
|
||||
{
|
||||
if (resources.ContainsKey(iid))
|
||||
{
|
||||
OnDestroy?.Invoke(this);
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
foreach (var r in resources)
|
||||
if (r.Value.IsAlive && (r.Value.Target as IResource).Instance.Name == path)
|
||||
return new AsyncReply<IResource>(r.Value.Target as IResource);
|
||||
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Put(IResource resource)
|
||||
{
|
||||
resources.Add(resource.Instance.Id, new WeakReference( resource));// new WeakReference<IResource>(resource));
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public AsyncReply<IResource> Retrieve(uint iid)
|
||||
{
|
||||
if (resources.ContainsKey(iid))
|
||||
{
|
||||
if (resources.ContainsKey(iid) && resources[iid].IsAlive)// .TryGetTarget(out r))
|
||||
return new AsyncReply<IResource>(resources[iid].Target as IResource);
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
if (resources.ContainsKey(iid) && resources[iid].IsAlive)// .TryGetTarget(out r))
|
||||
return new AsyncReply<IResource>(resources[iid].Target as IResource);
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
else
|
||||
return new AsyncReply<IResource>(null);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool Record(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Remove(IResource resource)
|
||||
{
|
||||
resources.Remove(resource.Instance.Id);
|
||||
return true;
|
||||
}
|
||||
public bool Remove(IResource resource)
|
||||
{
|
||||
resources.Remove(resource.Instance.Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public AsyncReply<bool> AddChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<bool> AddChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<bool> RemoveChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<bool> RemoveChild(IResource parent, IResource child)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<bool> AddParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<bool> AddParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncReply<bool> RemoveParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncReply<bool> RemoveParent(IResource child, IResource parent)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user