mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
EntityCore
This commit is contained in:
@ -35,6 +35,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Esyur.Resource.Template;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections;
|
||||
|
||||
namespace Esyur.Data
|
||||
{
|
||||
@ -1171,6 +1172,8 @@ namespace Esyur.Data
|
||||
if (value is IUserType)
|
||||
value = (value as IUserType).Get();
|
||||
|
||||
|
||||
// value = (List<>)value.ToArray();
|
||||
|
||||
if (value is Func<DistributedConnection, object>)
|
||||
//if (connection != null)
|
||||
@ -1188,8 +1191,22 @@ namespace Esyur.Data
|
||||
|
||||
|
||||
var t = value.GetType();
|
||||
|
||||
// Convert ICollection<T> to Array<T>
|
||||
if (!t.IsArray && typeof(ICollection).IsAssignableFrom(t))
|
||||
{
|
||||
var col = t.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ICollection<>));
|
||||
if (col.Count() == 0)
|
||||
return (DataType.Void, null);
|
||||
|
||||
var elementType = col.First().GetGenericArguments()[0];
|
||||
|
||||
value = new ArrayList((ICollection)value).ToArray(elementType);
|
||||
t = value.GetType();
|
||||
}
|
||||
|
||||
var isArray = t.IsArray;
|
||||
|
||||
if (isArray)
|
||||
t = t.GetElementType();
|
||||
|
||||
|
@ -259,8 +259,8 @@ namespace Esyur.Net.HTTP
|
||||
foreach (var resource in filters)
|
||||
if (resource.Execute(sender))
|
||||
return;
|
||||
|
||||
|
||||
sender.Response.Number = HTTPResponsePacket.ResponseCode.HTTP_SERVERERROR;
|
||||
sender.Send("Bad Request");
|
||||
sender.Close();
|
||||
}
|
||||
|
@ -800,6 +800,15 @@ namespace Esyur.Net.IIP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[ResourceAttribute]
|
||||
public string Username { get; set; }
|
||||
|
||||
[ResourceAttribute]
|
||||
public string Password { get; set; }
|
||||
|
||||
[ResourceAttribute]
|
||||
public string Domain { get; set; }
|
||||
/// <summary>
|
||||
/// Resource interface
|
||||
/// </summary>
|
||||
@ -809,8 +818,8 @@ namespace Esyur.Net.IIP
|
||||
{
|
||||
if (trigger == ResourceTrigger.Open)
|
||||
{
|
||||
if (Instance.Attributes.ContainsKey("username")
|
||||
&& Instance.Attributes.ContainsKey("password"))
|
||||
if (Username != null // Instance.Attributes.ContainsKey("username")
|
||||
&& Password != null)/// Instance.Attributes.ContainsKey("password"))
|
||||
{
|
||||
// assign domain from hostname if not provided
|
||||
|
||||
@ -818,16 +827,16 @@ namespace Esyur.Net.IIP
|
||||
|
||||
var address = host[0];
|
||||
var port = ushort.Parse(host[1]);
|
||||
var username = Instance.Attributes["username"].ToString();
|
||||
var username = Username;// Instance.Attributes["username"].ToString();
|
||||
|
||||
var domain = Instance.Attributes.ContainsKey("domain") ? Instance.Attributes["domain"].ToString() : address;
|
||||
var domain = Domain != null ? Domain : address;// Instance.Attributes.ContainsKey("domain") ? Instance.Attributes["domain"].ToString() : address;
|
||||
|
||||
session = new Session(new ClientAuthentication()
|
||||
, new HostAuthentication());
|
||||
|
||||
session.LocalAuthentication.Domain = domain;
|
||||
session.LocalAuthentication.Username = username;
|
||||
localPassword = DC.ToBytes(Instance.Attributes["password"].ToString());
|
||||
localPassword = DC.ToBytes(Password);// Instance.Attributes["password"].ToString());
|
||||
|
||||
openReply = new AsyncReply<bool>();
|
||||
var sock = new TCPSocket();
|
||||
|
@ -413,7 +413,7 @@ namespace Esyur.Net.IIP
|
||||
{
|
||||
Fetch(resourceId).Then(resource =>
|
||||
{
|
||||
resource.Instance.Attributes["name"] = name.GetString(0, (uint)name.Length);
|
||||
resource.Instance.Variables["name"] = name.GetString(0, (uint)name.Length);
|
||||
});
|
||||
}
|
||||
|
||||
@ -451,7 +451,8 @@ namespace Esyur.Net.IIP
|
||||
r.Instance.ResourceDestroyed -= Instance_ResourceDestroyed;
|
||||
// r.Instance.Children.OnAdd -= Children_OnAdd;
|
||||
// r.Instance.Children.OnRemoved -= Children_OnRemoved;
|
||||
r.Instance.Attributes.OnModified -= Attributes_OnModified;
|
||||
|
||||
//r.Instance.Attributes.OnModified -= Attributes_OnModified;
|
||||
|
||||
// subscribe
|
||||
r.Instance.ResourceEventOccurred += Instance_EventOccurred;
|
||||
@ -459,7 +460,8 @@ namespace Esyur.Net.IIP
|
||||
r.Instance.ResourceDestroyed += Instance_ResourceDestroyed;
|
||||
//r.Instance.Children.OnAdd += Children_OnAdd;
|
||||
//r.Instance.Children.OnRemoved += Children_OnRemoved;
|
||||
r.Instance.Attributes.OnModified += Attributes_OnModified;
|
||||
|
||||
//r.Instance.Attributes.OnModified += Attributes_OnModified;
|
||||
|
||||
// add it to attached resources so GC won't remove it from memory
|
||||
attachedResources.Add(r);
|
||||
@ -564,7 +566,8 @@ namespace Esyur.Net.IIP
|
||||
r.Instance.ResourceDestroyed -= Instance_ResourceDestroyed;
|
||||
//r.Instance.Children.OnAdd -= Children_OnAdd;
|
||||
//r.Instance.Children.OnRemoved -= Children_OnRemoved;
|
||||
r.Instance.Attributes.OnModified -= Attributes_OnModified;
|
||||
|
||||
//r.Instance.Attributes.OnModified -= Attributes_OnModified;
|
||||
|
||||
// subscribe
|
||||
r.Instance.ResourceEventOccurred += Instance_EventOccurred;
|
||||
@ -572,7 +575,8 @@ namespace Esyur.Net.IIP
|
||||
r.Instance.ResourceDestroyed += Instance_ResourceDestroyed;
|
||||
//r.Instance.Children.OnAdd += Children_OnAdd;
|
||||
//r.Instance.Children.OnRemoved += Children_OnRemoved;
|
||||
r.Instance.Attributes.OnModified += Attributes_OnModified;
|
||||
|
||||
//r.Instance.Attributes.OnModified += Attributes_OnModified;
|
||||
|
||||
// reply ok
|
||||
SendReply(IIPPacket.IIPPacketAction.ReattachResource, callback)
|
||||
|
@ -406,8 +406,6 @@ namespace Esyur.Net.Sockets
|
||||
Console.WriteLine("Level 2 {0}", ex2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Global.Log("TCPSocket", LogType.Error, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ namespace Esyur.Proxy
|
||||
#if NETSTANDARD
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
|
||||
if (typeInfo.IsSealed)
|
||||
throw new Exception("Sealed class can't be proxied.");
|
||||
if (typeInfo.IsSealed || typeInfo.IsAbstract)
|
||||
throw new Exception("Sealed/Abastract classes can't be proxied.");
|
||||
|
||||
var props = from p in typeInfo.GetProperties()
|
||||
where p.CanWrite && p.GetSetMethod().IsVirtual &&
|
||||
|
@ -28,12 +28,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Esyur.Data;
|
||||
using Esyur.Core;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Esyur.Resource
|
||||
{
|
||||
public delegate bool QueryFilter<T>(T value);
|
||||
|
||||
public interface IResource : IDestructible
|
||||
public interface IResource : IDestructible///, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
AsyncReply<bool> Trigger(ResourceTrigger trigger);
|
||||
|
@ -30,6 +30,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Esyur.Security.Permissions;
|
||||
using Esyur.Security.Authority;
|
||||
|
||||
namespace Esyur.Resource
|
||||
{
|
||||
@ -43,6 +45,13 @@ namespace Esyur.Resource
|
||||
bool Modify(IResource resource, string propertyName, object value, ulong age, DateTime dateTime);
|
||||
bool Remove(IResource resource);
|
||||
|
||||
//bool RemoveAttributes(IResource resource, string[] attributes = null);
|
||||
|
||||
//Structure GetAttributes(IResource resource, string[] attributes = null);
|
||||
|
||||
//bool SetAttributes(IResource resource, Structure attributes, bool clearAttributes = false);
|
||||
|
||||
|
||||
|
||||
AsyncReply<bool> AddChild(IResource parent, IResource child);
|
||||
AsyncReply<bool> RemoveChild(IResource parent, IResource child);
|
||||
|
@ -20,22 +20,14 @@ namespace Esyur.Resource
|
||||
{
|
||||
string name;
|
||||
|
||||
//IQueryable<IResource> children;//
|
||||
//AutoList<IResource, Instance> children;// = new AutoList<IResource, Instance>();
|
||||
WeakReference<IResource> resource;
|
||||
IStore store;
|
||||
//AutoList<IResource, Instance> parents;// = new AutoList<IResource>();
|
||||
//bool inherit;
|
||||
ResourceTemplate template;
|
||||
|
||||
AutoList<IPermissionsManager, Instance> managers;// = new AutoList<IPermissionManager, Instance>();
|
||||
AutoList<IPermissionsManager, Instance> managers;
|
||||
|
||||
|
||||
public delegate void ResourceModifiedEvent(IResource resource, string propertyName, object newValue);
|
||||
//public delegate void ResourceEventOccurredEvent(IResource resource, string eventName, string[] users, DistributedConnection[] connections, object[] args);
|
||||
|
||||
public delegate void ResourceEventOccurredEvent(IResource resource, object issuer, Session[] receivers, string eventName, object[] args);
|
||||
|
||||
public delegate void ResourceDestroyedEvent(IResource resource);
|
||||
|
||||
public event ResourceModifiedEvent ResourceModified;
|
||||
@ -44,7 +36,7 @@ namespace Esyur.Resource
|
||||
|
||||
bool loading = false;
|
||||
|
||||
KeyList<string, object> attributes;
|
||||
//KeyList<string, object> attributes;
|
||||
|
||||
List<ulong> ages = new List<ulong>();
|
||||
List<DateTime> modificationDates = new List<DateTime>();
|
||||
@ -53,17 +45,18 @@ namespace Esyur.Resource
|
||||
|
||||
uint id;
|
||||
|
||||
public KeyList<string, object> Variables { get; } = new KeyList<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Instance attributes are custom properties associated with the instance, a place to store information by IStore.
|
||||
/// </summary>
|
||||
public KeyList<string, object> Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
//public KeyList<string, object> Attributes
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return attributes;
|
||||
// }
|
||||
//}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
@ -72,6 +65,19 @@ namespace Esyur.Resource
|
||||
|
||||
public bool RemoveAttributes(string[] attributes = null)
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
/*
|
||||
IResource res;
|
||||
|
||||
if (!resource.TryGetTarget(out res))
|
||||
return false;
|
||||
|
||||
return store.RemoveAttributes(res, attributes);
|
||||
*/
|
||||
|
||||
/*
|
||||
if (attributes == null)
|
||||
this.attributes.Clear();
|
||||
else
|
||||
@ -81,10 +87,31 @@ namespace Esyur.Resource
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
public Structure GetAttributes(string[] attributes = null)
|
||||
{
|
||||
// @TODO
|
||||
Structure rt = new Structure();
|
||||
|
||||
if (attributes != null)
|
||||
{
|
||||
for (var i = 0; i < attributes.Length; i++)
|
||||
{
|
||||
var at = template.GetAttributeTemplate(attributes[i]);
|
||||
if (at != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rt;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
var st = new Structure();
|
||||
|
||||
if (attributes == null)
|
||||
@ -132,10 +159,31 @@ namespace Esyur.Resource
|
||||
}
|
||||
|
||||
return st;
|
||||
*/
|
||||
}
|
||||
|
||||
public bool SetAttributes(Structure attributes, bool clearAttributes = false)
|
||||
{
|
||||
|
||||
// @ TODO
|
||||
IResource res;
|
||||
|
||||
if (resource.TryGetTarget(out res))
|
||||
{
|
||||
foreach (var kv in attributes)
|
||||
{
|
||||
var at = template.GetAttributeTemplate(kv.Key);
|
||||
|
||||
if (at != null)
|
||||
if (at.Info.CanWrite)
|
||||
at.Info.SetValue(res, kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
|
||||
@ -183,6 +231,7 @@ namespace Esyur.Resource
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
@ -758,12 +807,15 @@ namespace Esyur.Resource
|
||||
IResource res;
|
||||
if (this.resource.TryGetTarget(out res))
|
||||
{
|
||||
//return store.Applicable(res, session, action, member, inquirer);
|
||||
|
||||
foreach (IPermissionsManager manager in managers)
|
||||
{
|
||||
var r = manager.Applicable(res, session, action, member, inquirer);
|
||||
if (r != Ruling.DontCare)
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Ruling.DontCare;
|
||||
@ -790,7 +842,7 @@ namespace Esyur.Resource
|
||||
this.name = name;
|
||||
this.instanceAge = age;
|
||||
|
||||
this.attributes = new KeyList<string, object>(this);
|
||||
//this.attributes = new KeyList<string, object>(this);
|
||||
//children = new AutoList<IResource, Instance>(this);
|
||||
//parents = new AutoList<IResource, Instance>(this);
|
||||
managers = new AutoList<IPermissionsManager, Instance>(this);
|
||||
|
42
Esyur/Resource/ResourceAttribute.cs
Normal file
42
Esyur/Resource/ResourceAttribute.cs
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2020 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esyur.Resource
|
||||
{
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ResourceAttribute : System.Attribute
|
||||
{
|
||||
|
||||
public ResourceAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
26
Esyur/Resource/Template/AttributeTemplate.cs
Normal file
26
Esyur/Resource/Template/AttributeTemplate.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Esyur.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esyur.Resource.Template
|
||||
{
|
||||
public class AttributeTemplate : MemberTemplate
|
||||
{
|
||||
public PropertyInfo Info
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public AttributeTemplate(ResourceTemplate template, byte index, string name)
|
||||
: base(template, MemberType.Attribute, index, name)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ namespace Esyur.Resource.Template
|
||||
Function = 0,
|
||||
Property = 1,
|
||||
Event = 2,
|
||||
Attribute = 3
|
||||
}
|
||||
|
||||
public byte Index => index;
|
||||
|
@ -19,6 +19,7 @@ namespace Esyur.Resource.Template
|
||||
List<FunctionTemplate> functions = new List<FunctionTemplate>();
|
||||
List<EventTemplate> events = new List<EventTemplate>();
|
||||
List<PropertyTemplate> properties = new List<PropertyTemplate>();
|
||||
List<AttributeTemplate> attributes = new List<AttributeTemplate>();
|
||||
int version;
|
||||
//bool isReady;
|
||||
|
||||
@ -88,6 +89,14 @@ namespace Esyur.Resource.Template
|
||||
return null;
|
||||
}
|
||||
|
||||
public AttributeTemplate GetAttributeTemplate(string attributeName)
|
||||
{
|
||||
foreach (var i in attributes)
|
||||
if (i.Name == attributeName)
|
||||
return i;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Guid ClassId
|
||||
{
|
||||
get { return classId; }
|
||||
@ -156,21 +165,31 @@ namespace Esyur.Resource.Template
|
||||
|
||||
foreach (var pi in propsInfo)
|
||||
{
|
||||
var ps = (ResourceProperty[])pi.GetCustomAttributes(typeof(ResourceProperty), true);
|
||||
if (ps.Length > 0)
|
||||
var rp = pi.GetCustomAttribute<ResourceProperty>(true);
|
||||
|
||||
if (rp != null)
|
||||
{
|
||||
var pt = new PropertyTemplate(this, i++, pi.Name, ps[0].ReadExpansion, ps[0].WriteExpansion, ps[0].Storage);
|
||||
var pt = new PropertyTemplate(this, i++, pi.Name, rp.ReadExpansion, rp.WriteExpansion, rp.Storage);
|
||||
pt.Info = pi;
|
||||
pt.Serilize = ps[0].Serialize;
|
||||
pt.Serilize = rp.Serialize;
|
||||
properties.Add(pt);
|
||||
}
|
||||
|
||||
var ra = pi.GetCustomAttribute<ResourceAttribute>(true);
|
||||
|
||||
if (ra != null)
|
||||
{
|
||||
var at = new AttributeTemplate(this, i++, pi.Name);
|
||||
at.Info = pi;
|
||||
attributes.Add(at);
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
foreach (var ei in eventsInfo)
|
||||
{
|
||||
var es = (ResourceEvent[])ei.GetCustomAttributes(typeof(ResourceEvent), true);
|
||||
var es = ei.GetCustomAttributes<ResourceEvent>(true).ToArray();
|
||||
if (es.Length > 0)
|
||||
{
|
||||
var et = new EventTemplate(this, i++, ei.Name, es[0].Expansion);
|
||||
@ -181,7 +200,7 @@ namespace Esyur.Resource.Template
|
||||
i = 0;
|
||||
foreach (MethodInfo mi in methodsInfo)
|
||||
{
|
||||
var fs = (ResourceFunction[])mi.GetCustomAttributes(typeof(ResourceFunction), true);
|
||||
var fs = mi.GetCustomAttributes<ResourceFunction>(true).ToArray();
|
||||
if (fs.Length > 0)
|
||||
{
|
||||
var ft = new FunctionTemplate(this, i++, mi.Name, mi.ReturnType == typeof(void), fs[0].Expansion);
|
||||
|
@ -501,10 +501,9 @@ namespace Esyur.Resource
|
||||
|
||||
}
|
||||
|
||||
public static T New<T>(string name, IStore store = null, IResource parent = null, IPermissionsManager manager = null, Structure attributes = null, Structure arguments = null, Structure properties = null)
|
||||
where T : IResource
|
||||
public static IResource New(Type type, string name, IStore store = null, IResource parent = null, IPermissionsManager manager = null, Structure attributes = null, Structure arguments = null, Structure properties = null)
|
||||
{
|
||||
var type = ResourceProxy.GetProxy<T>();
|
||||
type = ResourceProxy.GetProxy(type);
|
||||
|
||||
|
||||
/*
|
||||
@ -544,7 +543,7 @@ namespace Esyur.Resource
|
||||
{
|
||||
foreach (var p in properties)
|
||||
{
|
||||
var pi = typeof(T).GetProperty(p.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);
|
||||
var pi = type.GetProperty(p.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);
|
||||
if (pi != null)
|
||||
pi.SetValue(res, p.Value);
|
||||
}
|
||||
@ -553,7 +552,14 @@ namespace Esyur.Resource
|
||||
if (store != null || parent != null || res is IStore)
|
||||
Put(res, name, store, parent, null, 0, manager, attributes);
|
||||
|
||||
return (T)res;
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public static T New<T>(string name, IStore store = null, IResource parent = null, IPermissionsManager manager = null, Structure attributes = null, Structure arguments = null, Structure properties = null)
|
||||
where T : IResource
|
||||
{
|
||||
return (T)New(typeof(T), name, store, parent, manager, attributes, arguments, properties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -45,8 +45,8 @@ namespace Esyur.Stores
|
||||
{
|
||||
|
||||
resources.Add(resource.Instance.Id, resource);// new WeakReference<IResource>(resource));
|
||||
resource.Instance.Attributes["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
resource.Instance.Attributes["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
resource.Instance.Variables["children"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
resource.Instance.Variables["parents"] = new AutoList<IResource, Instance>(resource.Instance);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace Esyur.Stores
|
||||
{
|
||||
if (parent.Instance.Store == this)
|
||||
{
|
||||
(parent.Instance.Attributes["children"] as AutoList<IResource, Instance>).Add(child);
|
||||
(parent.Instance.Variables["children"] as AutoList<IResource, Instance>).Add(child);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
@ -111,7 +111,7 @@ namespace Esyur.Stores
|
||||
|
||||
if (resource.Instance.Store == this)
|
||||
{
|
||||
(resource.Instance.Attributes["parents"] as AutoList<IResource, Instance>).Add(parent);
|
||||
(resource.Instance.Variables["parents"] as AutoList<IResource, Instance>).Add(parent);
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
else
|
||||
@ -125,7 +125,7 @@ namespace Esyur.Stores
|
||||
|
||||
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var children = (resource.Instance.Attributes["children"] as AutoList<IResource, Instance>);
|
||||
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());
|
||||
@ -136,7 +136,7 @@ namespace Esyur.Stores
|
||||
|
||||
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
|
||||
{
|
||||
var parents = (resource.Instance.Attributes["parents"] as AutoList<IResource, Instance>);
|
||||
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());
|
||||
|
Reference in New Issue
Block a user