2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-09-13 12:43:17 +00:00
This commit is contained in:
2025-08-23 18:16:19 +03:00
parent c4b4a2e4cb
commit 0d4ea04ef4
21 changed files with 306 additions and 305 deletions

View File

@@ -19,7 +19,7 @@ namespace Esiur.AspNetCore.Example
[HttpGet(Name = "Get")]
public async AsyncReply<MyResource> Get()
{
return await Warehouse.Get<MyResource>("/sys/demo");
return await Warehouse.Default.Get<MyResource>("/sys/demo");
}
}
}

View File

@@ -56,12 +56,12 @@ var webSocketOptions = new WebSocketOptions()
app.UseWebSockets(webSocketOptions);
await Warehouse.Default.Put("sys", new MemoryStore());
await Warehouse.Default.Put("sys/service", new MyResource());
var server = await Warehouse.Default.Put("sys/server", new DistributedServer());
await Warehouse.Put("sys", new MemoryStore());
await Warehouse.Put("sys/service", new MyResource());
var server = await Warehouse.Put("sys/server", new DistributedServer());
await Warehouse.Open();
await Warehouse.Default.Open();
app.UseEsiur(new EsiurOptions() { Server = server });

View File

@@ -13,14 +13,16 @@ internal class Program
private static async Task Main(string[] args)
{
// Create a store to keep objects.
var system = await Warehouse.Put("sys", new MemoryStore());
// Create a distibuted server
var esiurServer = await Warehouse.Put("sys/server", new DistributedServer());
// Add your object to the store
var service = await Warehouse.Put("sys/demo", new Demo());
var wh = new Warehouse();
var http = await Warehouse.Put<HTTPServer>("sys/http", new HTTPServer() { Port = 8888 });
// Create a store to keep objects.
var system = await wh.Put("sys", new MemoryStore());
// Create a distibuted server
var esiurServer = await wh.Put("sys/server", new DistributedServer());
// Add your object to the store
var service = await wh.Put("sys/demo", new Demo());
var http = await wh.Put<HTTPServer>("sys/http", new HTTPServer() { Port = 8888 });
http.MapGet("{url}", (string url, HTTPConnection sender) =>
@@ -49,7 +51,7 @@ internal class Program
// Start your server
await Warehouse.Open();
await wh.Open();
Console.WriteLine("Running on http://localhost:8888");

View File

@@ -185,25 +185,7 @@ public class EntityStore : IStore
//throw new NotImplementedException();
}
public bool Remove(IResource resource)
{
var type = ResourceProxy.GetBaseType(resource);
var eid = TypesByType[type].PrimaryKey.GetValue(resource);
lock (DBLock)
{
if (DB[type].ContainsKey(eid))
{
DB[type].Remove(eid);
return true;
}
}
return false;
//throw new NotImplementedException();
}
public AsyncReply<bool> AddChild(IResource parent, IResource child)
{
throw new NotImplementedException();
@@ -290,4 +272,32 @@ public class EntityStore : IStore
{
OnDestroy?.Invoke(this);
}
public AsyncReply<bool> Remove(IResource resource)
{
var type = ResourceProxy.GetBaseType(resource);
var eid = TypesByType[type].PrimaryKey.GetValue(resource);
lock (DBLock)
{
if (DB[type].ContainsKey(eid))
{
DB[type].Remove(eid);
return new AsyncReply<bool>(true);
}
}
return new AsyncReply<bool>(false);
}
public AsyncReply<bool> Remove(string path)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Move(IResource resource, string newPath)
{
throw new NotImplementedException();
}
}

View File

@@ -225,7 +225,7 @@ public class MongoDBStore : IStore
var doc = value.AsBsonDocument;
if (doc["type"] == 0)
{
return Warehouse.Get<IResource>(doc["link"].AsString);
return Instance.Warehouse.Get<IResource>(doc["link"].AsString);
} // structure
else if (doc["type"] == 1)
{
@@ -845,7 +845,7 @@ public class MongoDBStore : IStore
foreach (var child in children)
{
var r = Warehouse.Get<T>(child);
var r = Instance.Warehouse.Get<T>(child);
if (r is AsyncReply<T>)
rt.Add(r);// (AsyncReply<T>)r);
}
@@ -855,41 +855,7 @@ public class MongoDBStore : IStore
}
}
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
{
if (resource == this)
{
return new AsyncBag<T>(null);
}
else
{
var parents = (string[])resource.Instance.Variables["parents"];
if (parents == null)
{
return new AsyncBag<T>(null);
}
var rt = new AsyncBag<T>();
foreach (var parent in parents)
{
var r = Warehouse.Get<T>(parent);
if (r is AsyncReply<T>)
rt.Add(r);// (AsyncReply<T>)r);
}
rt.Seal();
return rt;
}
}
public AsyncReply<bool> AddChild(IResource resource, IResource child)
{
@@ -920,4 +886,24 @@ public class MongoDBStore : IStore
{
throw new NotImplementedException();
}
AsyncReply<bool> IStore.Remove(IResource resource)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Remove(string path)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Move(IResource resource, string newPath)
{
throw new NotImplementedException();
}
public AsyncReply<T> Parent<T>(IResource resource, string name) where T : IResource
{
throw new NotImplementedException();
}
}

View File

@@ -19,7 +19,7 @@ namespace Esiur.Core
Connection.SendChunk(CallbackId, value);
}
public void Progress(int value, int max) {
public void Progress(uint value, uint max) {
if (Ended)
throw new Exception("Execution has ended.");
@@ -27,6 +27,15 @@ namespace Esiur.Core
Connection.SendProgress(CallbackId, value, max);
}
public void Warning(byte level, string message)
{
if (Ended)
throw new Exception("Execution has ended.");
Connection.SendWarning(CallbackId, level, message);
}
public DistributedConnection Connection { get; internal set; }

View File

@@ -42,7 +42,7 @@ public static class Codec
//delegate AsyncReply AsyncParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence);
delegate object AsyncParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence);
delegate object SyncParser(byte[] data, uint offset, uint length);
delegate object SyncParser(byte[] data, uint offset, uint length, Warehouse warehouse);
static AsyncParser[][] FixedAsyncParsers = new AsyncParser[][]
{
@@ -211,7 +211,7 @@ public static class Codec
}
}
public static (uint, object) ParseSync(byte[] data, uint offset, TransmissionType? dataType = null)
public static (uint, object) ParseSync(byte[] data, uint offset, Warehouse warehouse, TransmissionType? dataType = null)
{
uint len = 0;
@@ -232,15 +232,15 @@ public static class Codec
if (tt.Class == TransmissionTypeClass.Fixed)
{
return (len, FixedParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength));
return (len, FixedParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
}
else if (tt.Class == TransmissionTypeClass.Dynamic)
{
return (len, DynamicParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength));
return (len, DynamicParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
}
else //if (tt.Class == TransmissionTypeClass.Typed)
{
return (len, TypedParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength));
return (len, TypedParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
}
}
/// <summary>

View File

@@ -19,7 +19,7 @@ public static class DataDeserializer
return null;
}
public static object NullParser(byte[] data, uint offset, uint length)
public static object NullParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return null;
}
@@ -29,7 +29,7 @@ public static class DataDeserializer
return true;
}
public static object BooleanTrueParser(byte[] data, uint offset, uint length)
public static object BooleanTrueParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return true;
}
@@ -39,7 +39,7 @@ public static class DataDeserializer
return false;
}
public static object BooleanFalseParser(byte[] data, uint offset, uint length)
public static object BooleanFalseParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return false;
}
@@ -49,7 +49,7 @@ public static class DataDeserializer
return NotModified.Default;
}
public static object NotModifiedParser(byte[] data, uint offset, uint length)
public static object NotModifiedParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return NotModified.Default;
}
@@ -58,7 +58,7 @@ public static class DataDeserializer
{
return data[offset];
}
public static object UInt8Parser(byte[] data, uint offset, uint length)
public static object UInt8Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return data[offset];
}
@@ -67,7 +67,7 @@ public static class DataDeserializer
{
return (sbyte)data[offset];
}
public static object Int8Parser(byte[] data, uint offset, uint length)
public static object Int8Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return (sbyte)data[offset];
}
@@ -78,7 +78,7 @@ public static class DataDeserializer
return *(char*)ptr;
}
public static unsafe object Char16Parser(byte[] data, uint offset, uint length)
public static unsafe object Char16Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(char*)ptr;
@@ -89,7 +89,7 @@ public static class DataDeserializer
return (char)data[offset];
}
public static object Char8Parser(byte[] data, uint offset, uint length)
public static object Char8Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return (char)data[offset];
}
@@ -101,7 +101,7 @@ public static class DataDeserializer
return *(short*)ptr;
}
public static unsafe object Int16Parser(byte[] data, uint offset, uint length)
public static unsafe object Int16Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(short*)ptr;
@@ -113,7 +113,7 @@ public static class DataDeserializer
return *(ushort*)ptr;
}
public static unsafe object UInt16Parser(byte[] data, uint offset, uint length)
public static unsafe object UInt16Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(ushort*)ptr;
@@ -125,7 +125,7 @@ public static class DataDeserializer
return *(int*)ptr;
}
public static unsafe object Int32Parser(byte[] data, uint offset, uint length)
public static unsafe object Int32Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(int*)ptr;
@@ -137,7 +137,7 @@ public static class DataDeserializer
return *(uint*)ptr;
}
public static unsafe object UInt32Parser(byte[] data, uint offset, uint length)
public static unsafe object UInt32Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(uint*)ptr;
@@ -150,7 +150,7 @@ public static class DataDeserializer
return *(float*)ptr;
}
public static unsafe object Float32Parser(byte[] data, uint offset, uint length)
public static unsafe object Float32Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(float*)ptr;
@@ -162,7 +162,7 @@ public static class DataDeserializer
return *(double*)ptr;
}
public static unsafe object Float64Parser(byte[] data, uint offset, uint length)
public static unsafe object Float64Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(double*)ptr;
@@ -175,7 +175,7 @@ public static class DataDeserializer
return *(decimal*)ptr;
}
public static unsafe object Float128Parser(byte[] data, uint offset, uint length)
public static unsafe object Float128Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(decimal*)ptr;
@@ -189,7 +189,7 @@ public static class DataDeserializer
return new Int128(*(ulong*)ptr1, *(ulong*)ptr2);
}
public static unsafe object Int128Parser(byte[] data, uint offset, uint length)
public static unsafe object Int128Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr1 = &data[offset])
fixed (byte* ptr2 = &data[offset + 8])
@@ -203,7 +203,7 @@ public static class DataDeserializer
return new UInt128(*(ulong*)ptr1, *(ulong*)ptr2);
}
public static unsafe object UInt128Parser(byte[] data, uint offset, uint length)
public static unsafe object UInt128Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr1 = &data[offset])
fixed (byte* ptr2 = &data[offset + 8])
@@ -216,7 +216,7 @@ public static class DataDeserializer
return *(long*)ptr;
}
public static unsafe object Int64Parser(byte[] data, uint offset, uint length)
public static unsafe object Int64Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(long*)ptr;
@@ -229,7 +229,7 @@ public static class DataDeserializer
return *(ulong*)ptr;
}
public static unsafe object UInt64Parser(byte[] data, uint offset, uint length)
public static unsafe object UInt64Parser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return *(ulong*)ptr;
@@ -242,7 +242,7 @@ public static class DataDeserializer
}
public static unsafe object DateTimeParser(byte[] data, uint offset, uint length)
public static unsafe object DateTimeParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return new DateTime(*(long*)ptr, DateTimeKind.Utc);
@@ -257,7 +257,7 @@ public static class DataDeserializer
return connection.Fetch(data[offset], requestSequence);
}
public static unsafe object ResourceParser8(byte[] data, uint offset, uint length)
public static unsafe object ResourceParser8(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return new ResourceId(false, data[offset]);
}
@@ -267,10 +267,10 @@ public static class DataDeserializer
if (connection == null)
return new ResourceId(true, data[offset]);
else
return Warehouse.GetById(data[offset]);
return connection.Instance.Warehouse.GetById(data[offset]);
}
public static unsafe object LocalResourceParser8(byte[] data, uint offset, uint length)
public static unsafe object LocalResourceParser8(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return new ResourceId(true, data[offset]);
}
@@ -284,7 +284,7 @@ public static class DataDeserializer
return connection.Fetch(*(ushort*)ptr, requestSequence);
}
public static unsafe object ResourceParser16(byte[] data, uint offset, uint length)
public static unsafe object ResourceParser16(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return new ResourceId(false, *(ushort*)ptr);
@@ -297,13 +297,13 @@ public static class DataDeserializer
if (connection == null)
return new ResourceId(true, *(ushort*)ptr);
else
return Warehouse.GetById(*(ushort*)ptr);
return connection.Instance.Warehouse.GetById(*(ushort*)ptr);
}
public static unsafe object LocalResourceParser16(byte[] data, uint offset, uint length)
public static unsafe object LocalResourceParser16(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return Warehouse.GetById(*(ushort*)ptr);
return new ResourceId(true, *(ushort*)ptr);
}
public static unsafe object ResourceParser32Async(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
@@ -315,7 +315,7 @@ public static class DataDeserializer
return connection.Fetch(*(uint*)ptr, requestSequence);
}
public static unsafe object ResourceParser32(byte[] data, uint offset, uint length)
public static unsafe object ResourceParser32(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return new ResourceId(false, *(uint*)ptr);
@@ -328,10 +328,10 @@ public static class DataDeserializer
if (connection == null)
return new ResourceId(true, *(uint*)ptr);
else
return Warehouse.GetById(*(uint*)ptr);
return connection.Instance.Warehouse.GetById(*(uint*)ptr);
}
public static unsafe object LocalResourceParser32(byte[] data, uint offset, uint length)
public static unsafe object LocalResourceParser32(byte[] data, uint offset, uint length, Warehouse warehouse)
{
fixed (byte* ptr = &data[offset])
return new ResourceId(true, *(uint*)ptr);
@@ -343,7 +343,7 @@ public static class DataDeserializer
return data.Clip(offset, length);
}
public static unsafe object RawDataParser(byte[] data, uint offset, uint length)
public static unsafe object RawDataParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return data.Clip(offset, length);
}
@@ -354,7 +354,7 @@ public static class DataDeserializer
return data.GetString(offset, length);
}
public static unsafe object StringParser(byte[] data, uint offset, uint length)
public static unsafe object StringParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
return data.GetString(offset, length);
}
@@ -369,7 +369,7 @@ public static class DataDeserializer
length -= 16;
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var initRecord = (TypeTemplate template) =>
{
@@ -436,16 +436,16 @@ public static class DataDeserializer
}
public static unsafe object RecordParser(byte[] data, uint offset, uint length)
public static unsafe object RecordParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var classId = data.GetUUID(offset);
offset += 16;
length -= 16;
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var template = warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var r = ListParser(data, offset, length);
var r = ListParser(data, offset, length, warehouse);
var ar = (object[])r;
@@ -490,7 +490,7 @@ public static class DataDeserializer
throw new NotImplementedException();
}
public static unsafe object ConstantParser(byte[] data, uint offset, uint length)
public static unsafe object ConstantParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
throw new NotImplementedException();
}
@@ -502,7 +502,7 @@ public static class DataDeserializer
offset += 16;
var index = data[offset++];
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Enum);
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, TemplateType.Enum);
if (template != null)
{
@@ -521,14 +521,14 @@ public static class DataDeserializer
}
}
public static unsafe object EnumParser(byte[] data, uint offset, uint length)
public static unsafe object EnumParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var classId = data.GetUUID(offset);
offset += 16;
var index = data[offset++];
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Enum);
var template = warehouse.GetTemplateByClassId(classId, TemplateType.Enum);
if (template != null)
{
@@ -566,13 +566,13 @@ public static class DataDeserializer
return rt;
}
public static object RecordListParser(byte[] data, uint offset, uint length)
public static object RecordListParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var rt = new List<IRecord>();
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
rt.Add(reply as IRecord);
@@ -614,13 +614,13 @@ public static class DataDeserializer
}
public static object ResourceListParser(byte[] data, uint offset, uint length)
public static object ResourceListParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var rt = new List<IResource>();
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
rt.Add(reply as IResource);
@@ -661,13 +661,13 @@ public static class DataDeserializer
return rt;
}
public static object ListParser(byte[] data, uint offset, uint length)
public static object ListParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var rt = new List<object>();
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
rt.Add(reply);
@@ -685,13 +685,13 @@ public static class DataDeserializer
}
public static (uint, ulong, object[]) LimitedCountListParser(byte[] data, uint offset, ulong length, uint countLimit = uint.MaxValue)
public static (uint, ulong, object[]) LimitedCountListParser(byte[] data, uint offset, ulong length, Warehouse warehouse, uint countLimit = uint.MaxValue)
{
var rt = new List<object>();
while (length > 0 && rt.Count < countLimit)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
rt.Add(reply);
@@ -720,7 +720,9 @@ public static class DataDeserializer
offset += valueCs;
length -= valueCs;
var map = (IMap)Activator.CreateInstance(typeof(Map<,>).MakeGenericType(keyRepType.GetRuntimeType(), valueRepType.GetRuntimeType()));
var wh = connection.Instance.Warehouse;
var map = (IMap)Activator.CreateInstance(typeof(Map<,>).MakeGenericType(keyRepType.GetRuntimeType(wh), valueRepType.GetRuntimeType(wh)));
var rt = new AsyncReply();
@@ -758,7 +760,7 @@ public static class DataDeserializer
}
public static object TypedMapParser(byte[] data, uint offset, uint length)
public static object TypedMapParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
// get key type
var (keyCs, keyRepType) = RepresentationType.Parse(data, offset);
@@ -769,14 +771,14 @@ public static class DataDeserializer
offset += valueCs;
length -= valueCs;
var map = (IMap)Activator.CreateInstance(typeof(Map<,>).MakeGenericType(keyRepType.GetRuntimeType(), valueRepType.GetRuntimeType()));
var map = (IMap)Activator.CreateInstance(typeof(Map<,>).MakeGenericType(keyRepType.GetRuntimeType(warehouse), valueRepType.GetRuntimeType(warehouse)));
var results = new List<object>();
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
results.Add(reply);
@@ -799,6 +801,7 @@ public static class DataDeserializer
public static AsyncReply TupleParserAsync(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)
{
var results = new AsyncBag<object>();
var rt = new AsyncReply();
@@ -810,7 +813,7 @@ public static class DataDeserializer
for (var i = 0; i < tupleSize; i++)
{
var (cs, rep) = RepresentationType.Parse(data, offset);
types.Add(rep.GetRuntimeType());
types.Add(rep.GetRuntimeType(connection.Instance.Warehouse));
offset += cs;
length -= cs;
}
@@ -871,7 +874,7 @@ public static class DataDeserializer
return rt;
}
public static object TupleParser(byte[] data, uint offset, uint length)
public static object TupleParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
var results = new List<object>();
@@ -884,14 +887,14 @@ public static class DataDeserializer
for (var i = 0; i < tupleSize; i++)
{
var (cs, rep) = RepresentationType.Parse(data, offset);
types.Add(rep.GetRuntimeType());
types.Add(rep.GetRuntimeType(warehouse));
offset += cs;
length -= cs;
}
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
results.Add(reply);
@@ -951,7 +954,7 @@ public static class DataDeserializer
offset += hdrCs;
length -= hdrCs;
var runtimeType = rep.GetRuntimeType();
var runtimeType = rep.GetRuntimeType(connection.Instance.Warehouse);
rt.ArrayType = runtimeType;
@@ -975,7 +978,7 @@ public static class DataDeserializer
return rt;
}
public static object TypedListParser(byte[] data, uint offset, uint length)
public static object TypedListParser(byte[] data, uint offset, uint length, Warehouse warehouse)
{
// get the type
@@ -984,13 +987,13 @@ public static class DataDeserializer
offset += hdrCs;
length -= hdrCs;
var runtimeType = rep.GetRuntimeType();
var runtimeType = rep.GetRuntimeType(warehouse);
var list = new List<object>();
while (length > 0)
{
var (cs, reply) = Codec.ParseSync(data, offset);
var (cs, reply) = Codec.ParseSync(data, offset, warehouse);
list.Add(reply);

View File

@@ -117,7 +117,7 @@ public static class DataSerializer
if (value == null)
return (TransmissionTypeIdentifier.Null, new byte[0]);
var template = Warehouse.GetTemplateByType(value.GetType());
var template = connection.Instance.Warehouse.GetTemplateByType(value.GetType());
var intVal = Convert.ChangeType(value, (value as Enum).GetTypeCode());
@@ -390,7 +390,7 @@ public static class DataSerializer
var rt = new List<byte>();// BinaryList();
var record = (IRecord)value;
var template = Warehouse.GetTemplateByType(record.GetType());
var template = connection.Instance.Warehouse.GetTemplateByType(record.GetType());
rt.AddRange(template.ClassId.Data);

View File

@@ -136,12 +136,12 @@ namespace Esiur.Data
st.SetNotNull(flag);
}
public Type? GetRuntimeType()
public Type? GetRuntimeType(Warehouse warehouse)
{
if (Identifier == RepresentationTypeIdentifier.TypedList)
{
var sub = SubTypes?[0].GetRuntimeType();
var sub = SubTypes?[0].GetRuntimeType(warehouse);
if (sub == null)
return null;
@@ -151,11 +151,11 @@ namespace Esiur.Data
}
else if (Identifier == RepresentationTypeIdentifier.TypedMap)
{
var subs = SubTypes.Select(x => x.GetRuntimeType()).ToArray();
var subs = SubTypes.Select(x => x.GetRuntimeType(warehouse)).ToArray();
var rt = typeof(Map<,>).MakeGenericType(subs);
return rt;
}
return Identifier switch
{
(RepresentationTypeIdentifier.Void) => typeof(void),
@@ -177,9 +177,9 @@ namespace Esiur.Data
(RepresentationTypeIdentifier.DateTime) => Nullable ? typeof(DateTime?) : typeof(DateTime),
(RepresentationTypeIdentifier.Resource) => typeof(IResource),
(RepresentationTypeIdentifier.Record) => typeof(IRecord),
(RepresentationTypeIdentifier.TypedRecord) => Warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Record)?.DefinedType,
(RepresentationTypeIdentifier.TypedResource) => Warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Resource)?.DefinedType,
(RepresentationTypeIdentifier.Enum) => Warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Enum)?.DefinedType,
(RepresentationTypeIdentifier.TypedRecord) => warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Record)?.DefinedType,
(RepresentationTypeIdentifier.TypedResource) => warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Resource)?.DefinedType,
(RepresentationTypeIdentifier.Enum) =>warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Enum)?.DefinedType,
_ => null
};
@@ -194,7 +194,6 @@ namespace Esiur.Data
public RepresentationType[]? SubTypes = null;
public RepresentationType ToNullable()
{
return new RepresentationType(Identifier, true, UUID, SubTypes);

View File

@@ -19,7 +19,7 @@ public class IIPoHTTP : HTTPFilter
IIPPacketRequest action = (IIPPacketRequest)Convert.ToByte(sender.Request.Query["a"]);
if (action == IIPPacketRequest.QueryLink)
if (action == IIPPacketRequest.Query)
{
EntryPoint.Query(sender.Request.Query["l"], null).Then(x =>
{

View File

@@ -666,7 +666,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
var dataType = authPacket.DataType.Value;
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, dataType);
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
var rt = (Map<byte, object>)parsed;
@@ -793,7 +793,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
else if (authPacket.Event == IIPAuthPacketEvent.IAuthPlain)
{
var dataType = authPacket.DataType.Value;
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, dataType);
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
var rt = (Map<byte, object>)parsed;
var headers = rt.Select(x => new KeyValuePair<IIPAuthPacketIAuthHeader, object>((IIPAuthPacketIAuthHeader)x.Key, x.Value));
@@ -833,7 +833,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
else if (authPacket.Event == IIPAuthPacketEvent.IAuthHashed)
{
var dataType = authPacket.DataType.Value;
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, dataType);
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
var rt = (Map<byte, object>)parsed;
@@ -896,7 +896,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
var dataType = authPacket.DataType.Value;
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, dataType);
var (_, parsed) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
var rt = (Map<byte, object>)parsed;
@@ -1154,7 +1154,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
var reference = authPacket.Reference;
var dataType = authPacket.DataType.Value;
var (_, value) = Codec.ParseSync(data, dataType.Offset, dataType);
var (_, value) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
Server.Membership.AuthorizePlain(session, reference, value)
.Then(x => ProcessAuthorization(x));
@@ -1698,7 +1698,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
}
public AsyncBag<T> Parent<T>(IResource resource, string name) where T : IResource
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
{
throw new NotImplementedException();
}
@@ -1723,8 +1723,5 @@ public partial class DistributedConnection : NetworkConnection, IStore
throw new NotImplementedException();
}
AsyncReply<T> IStore.Parent<T>(IResource resource, string name)
{
throw new NotImplementedException();
}
}

View File

@@ -252,6 +252,11 @@ partial class DistributedConnection
SendReply(IIPPacketReply.Progress, callbackId, value, max);
}
internal void SendWarning(uint callbackId, byte level, string message)
{
SendReply(IIPPacketReply.Warning, callbackId, level, message);
}
internal void SendChunk(uint callbackId, object chunk)
{
SendReply(IIPPacketReply.Chunk, callbackId, chunk);
@@ -320,7 +325,7 @@ partial class DistributedConnection
return;
}
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength)
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength, Instance.Warehouse)
as object[];
var errorCode = (ushort)args[0];
@@ -339,7 +344,7 @@ partial class DistributedConnection
return;
}
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength)
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength, Instance.Warehouse)
as object[];
var current = (uint)args[0];
@@ -358,7 +363,7 @@ partial class DistributedConnection
return;
}
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength)
var args = DataDeserializer.ListParser(data, dataType.Offset, (uint)dataType.ContentLength, Instance.Warehouse)
as object[];
var level = (byte)args[0];
@@ -395,7 +400,7 @@ partial class DistributedConnection
void IIPNotificationResourceDestroyed(TransmissionType dataType, byte[] data)
{
var (size, rt) = Codec.ParseSync(data, dataType.Offset, dataType);
var (size, rt) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
var resourceId = (uint)rt;
@@ -428,7 +433,7 @@ partial class DistributedConnection
{
// resourceId, index, value
var (valueOffset, valueSize, args) =
DataDeserializer.LimitedCountListParser(data, dataType.Offset, dataType.ContentLength, 2);
DataDeserializer.LimitedCountListParser(data, dataType.Offset, dataType.ContentLength, Instance.Warehouse, 2);
var rid = (uint)args[0];
var index = (byte)args[1];
@@ -468,7 +473,7 @@ partial class DistributedConnection
// resourceId, index, value
var (valueOffset, valueSize, args) =
DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 2);
dataType.ContentLength, Instance.Warehouse, 2);
var resourceId = (uint)args[0];
var index = (byte)args[1];
@@ -515,7 +520,7 @@ partial class DistributedConnection
void IIPRequestAttachResource(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceId = (uint)value;
@@ -572,7 +577,7 @@ partial class DistributedConnection
// resourceId, index, value
var (valueOffset, valueSize, args) =
DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 2);
dataType.ContentLength, Instance.Warehouse, 2);
var resourceId = (uint)args[0];
var age = (ulong)args[1];
@@ -628,7 +633,7 @@ partial class DistributedConnection
void IIPRequestDetachResource(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceId = (uint)value;
@@ -720,7 +725,7 @@ partial class DistributedConnection
void IIPRequestDeleteResource(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceId = (uint)value;
@@ -750,7 +755,7 @@ partial class DistributedConnection
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength);
dataType.ContentLength, Instance.Warehouse);
var resourceId = (uint)args[0];
var name = (string)args[1];
@@ -792,7 +797,7 @@ partial class DistributedConnection
void IIPRequestLinkTemplates(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceLink = (string)value;
@@ -813,7 +818,7 @@ partial class DistributedConnection
var templates = TypeTemplate.GetDependencies(r.Instance.Template, Instance.Warehouse);
// Send
SendReply(IIPPacketReply.Completed, callback, templates.Select(x=>x.Content).ToArray());
SendReply(IIPPacketReply.Completed, callback, templates.Select(x => x.Content).ToArray());
};
@@ -825,7 +830,7 @@ partial class DistributedConnection
void IIPRequestTemplateFromClassName(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var className = (string)value;
@@ -845,7 +850,7 @@ partial class DistributedConnection
void IIPRequestTemplateFromClassId(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var classId = new UUID((byte[])value);
@@ -867,7 +872,7 @@ partial class DistributedConnection
void IIPRequestTemplateFromResourceId(uint callback, TransmissionType dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(data, 0, dataType);
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceId = (uint)value;
@@ -889,7 +894,7 @@ partial class DistributedConnection
void IIPRequestGetResourceIdByLink(uint callback, TransmissionType dataType, byte[] data)
{
var (_, parsed) = Codec.ParseSync(data, 0, dataType);
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceLink = (string)parsed;
Action<IResource> queryCallback = (r) =>
@@ -917,7 +922,7 @@ partial class DistributedConnection
void IIPRequestQueryResources(uint callback, TransmissionType dataType, byte[] data)
{
var (_, parsed) = Codec.ParseSync(data, 0, dataType);
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
var resourceLink = (string)parsed;
@@ -976,7 +981,7 @@ partial class DistributedConnection
void IIPRequestProcedureCall(uint callback, TransmissionType dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 1);
dataType.ContentLength, Instance.Warehouse, 1);
var procedureCall = (string)args[0];
@@ -1036,7 +1041,7 @@ partial class DistributedConnection
void IIPRequestStaticCall(uint callback, TransmissionType dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 2);
dataType.ContentLength, Instance.Warehouse, 2);
var classId = new UUID((byte[])args[0]);
var index = (byte)args[1];
@@ -1113,7 +1118,7 @@ partial class DistributedConnection
void IIPRequestInvokeFunction(uint callback, TransmissionType dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 2);
dataType.ContentLength, Instance.Warehouse, 2);
var resourceId = (uint)args[0];
var index = (byte)args[1];
@@ -1370,7 +1375,7 @@ partial class DistributedConnection
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength);
dataType.ContentLength, Instance.Warehouse);
var resourceId = (uint)args[0];
var index = (byte)args[1];
@@ -1429,7 +1434,7 @@ partial class DistributedConnection
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength);
dataType.ContentLength, Instance.Warehouse);
var resourceId = (uint)args[0];
var index = (byte)args[1];
@@ -1490,7 +1495,7 @@ partial class DistributedConnection
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, 2);
dataType.ContentLength, Instance.Warehouse, 2);
var rid = (uint)args[0];
var index = (byte)args[1];
@@ -1795,7 +1800,7 @@ partial class DistributedConnection
var age = (ulong)args[1];
var link = (string)args[2];
var hops = (byte)args[3];
var pv = (PropertyValue[])args[4];
var pvData = (byte[])args[4];
DistributedResource dr;
TypeTemplate template = null;
@@ -1817,30 +1822,12 @@ partial class DistributedConnection
var initResource = (DistributedResource ok) =>
{
var (_, parsed) = Codec.ParseAsync(content, 0, this, newSequence, transmissionType);
var parsedReply = DataDeserializer.PropertyValueArrayParserAsync(pvData, 0, (uint)pvData.Length, this, newSequence);// Codec.proper (content, 0, this, newSequence, transmissionType);
if (parsed is AsyncReply parsedReply)
parsedReply.Then(results =>
{
parsedReply.Then(results =>
{
var ar = results as object[];
var pvs = new List<PropertyValue>();
for (var i = 0; i < ar.Length; i += 3)
pvs.Add(new PropertyValue(ar[i + 2], Convert.ToUInt64(ar[i]), (DateTime)ar[i + 1]));
dr._Attach(pvs.ToArray());
resourceRequests.Remove(id);
// move from needed to attached.
neededResources.Remove(id);
attachedResources[id] = new WeakReference<DistributedResource>(dr);
reply.Trigger(dr);
}).Error(ex => reply.TriggerError(ex));
}
else
{
var ar = parsed as object[];
var ar = results as object[];
var pvs = new List<PropertyValue>();
@@ -1853,7 +1840,8 @@ partial class DistributedConnection
neededResources.Remove(id);
attachedResources[id] = new WeakReference<DistributedResource>(dr);
reply.Trigger(dr);
}
}).Error(ex => reply.TriggerError(ex));
};
@@ -2063,7 +2051,7 @@ partial class DistributedConnection
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength);
dataType.ContentLength, Instance.Warehouse);
var peerTime = (DateTime)args[0];
var interval = (uint)args[0];

View File

@@ -153,7 +153,7 @@ public class ResourceGenerator : ISourceGenerator
try
{
var con = Warehouse.Get<DistributedConnection>(url[1] + "://" + url[2]).Wait(20000);
var con = Warehouse.Default.Get<DistributedConnection>(url[1] + "://" + url[2]).Wait(20000);
var templates = con.GetLinkTemplates(url[3]).Wait(60000);
cache[path] = templates;

View File

@@ -186,7 +186,7 @@ public static class TemplateGenerator
throw new Exception("Invalid IIP URL");
var path = urlRegex.Split(url);
var con = Warehouse.Get<DistributedConnection>(path[1] + "://" + path[2],
var con = Warehouse.Default.Get<DistributedConnection>(path[1] + "://" + path[2],
!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null
).Wait(20000);
@@ -198,7 +198,7 @@ public static class TemplateGenerator
var templates = con.GetLinkTemplates(path[3]).Wait(60000);
// no longer needed
Warehouse.Remove(con);
Warehouse.Default.Remove(con);
var dstDir = new DirectoryInfo(tempDir ? Path.GetTempPath() + Path.DirectorySeparatorChar
+ Misc.Global.GenerateCode(20) + Path.DirectorySeparatorChar + dir : dir);

View File

@@ -63,7 +63,7 @@ public interface IStore : IResource
AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource;
AsyncReply<T> Parent<T>(IResource resource, string name) where T : IResource;
AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource;

View File

@@ -13,10 +13,7 @@ public abstract class Store<T> : IStore where T : IResource
public event DestroyedEvent OnDestroy;
public abstract AsyncReply<bool> AddChild(IResource parent, IResource child);
public abstract AsyncReply<bool> AddParent(IResource child, IResource parent);
public abstract AsyncBag<T1> Children<T1>(IResource resource, string name) where T1 : IResource;
public virtual void Destroy()
@@ -33,25 +30,29 @@ public abstract class Store<T> : IStore where T : IResource
public abstract bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime);
public abstract AsyncBag<T1> Parents<T1>(IResource resource, string name) where T1 : IResource;
public abstract AsyncReply<bool> Put(IResource resource);
public abstract bool Record(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime);
public abstract bool Remove(IResource resource);
public abstract AsyncReply<bool> RemoveChild(IResource parent, IResource child);
public abstract AsyncReply<bool> RemoveParent(IResource child, IResource parent);
public abstract AsyncReply<bool> Trigger(ResourceTrigger trigger);
public async AsyncReply<T> New(string name = null, object attributes = null, object properties = null)
{
var resource = await Warehouse.New<T>(name, this, null, null, attributes, properties);
resource.Instance.Managers.AddRange(this.Instance.Managers.ToArray());
return resource;
}
//public async AsyncReply<T> New(string name = null, object attributes = null, object properties = null)
//{
// var resource = await Warehouse.New<T>(name, this, null, null, attributes, properties);
// resource.Instance.Managers.AddRange(this.Instance.Managers.ToArray());
// return resource;
//}
public abstract AsyncReply<bool> Remove(IResource resource);
public abstract AsyncReply<bool> Remove(string path);
public abstract AsyncReply<bool> Move(IResource resource, string newPath);
public abstract AsyncBag<T1> Parents<T1>(IResource resource, string name) where T1 : IResource;
}

View File

@@ -887,7 +887,7 @@ public class TypeTemplate
offset += dts;
(dts, var value) = Codec.ParseSync(data, offset);
(dts, var value) = Codec.ParseSync(data, offset, Warehouse.Default);
offset += dts;

View File

@@ -65,18 +65,18 @@ public class MemoryStore : IStore
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);
}
else
return new AsyncReply<IResource>(null);
}
//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);
// }
// else
// return new AsyncReply<IResource>(null);
//}
public AsyncReply<bool> Trigger(ResourceTrigger trigger)
{
@@ -104,33 +104,29 @@ public class MemoryStore : IStore
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 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 AsyncReply<bool> AddParent(IResource resource, IResource parent)
//{
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);
}
// 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)
{
@@ -157,4 +153,20 @@ public class MemoryStore : IStore
else
return new AsyncBag<T>(parents.Where(x => x is T && x.Instance.Name == name).Select(x => (T)x).ToArray());
}
AsyncReply<bool> IStore.Remove(IResource resource)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Remove(string path)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Move(IResource resource, string newPath)
{
throw new NotImplementedException();
}
}

View File

@@ -42,7 +42,7 @@ public class TemporaryStore : IStore
public AsyncReply<bool> Put(IResource resource)
{
resources.Add(resource.Instance.Id, new WeakReference(resource));// new WeakReference<IResource>(resource));
resources.Add(resource.Instance.Id, new WeakReference(resource));
return new AsyncReply<bool>(true);
}
@@ -74,41 +74,34 @@ public class TemporaryStore : IStore
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)
{
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> RemoveParent(IResource child, IResource parent)
{
throw new NotImplementedException();
}
public AsyncBag<T> Children<T>(IResource resource, string name) where T : IResource
{
throw new NotImplementedException();
}
AsyncReply<bool> IStore.Remove(IResource resource)
{
resources.Remove(resource.Instance.Id);
return new AsyncReply<bool>(true);
}
public AsyncReply<bool> Remove(string path)
{
throw new NotImplementedException();
}
public AsyncReply<bool> Move(IResource resource, string newPath)
{
throw new NotImplementedException();
}
public AsyncBag<T> Parents<T>(IResource resource, string name) where T : IResource
{

View File

@@ -107,8 +107,7 @@ namespace Test
//Console.WriteLine(g);
var hhhh = Warehouse.GetTemplateByType(typeof(IMyRecord));
var a = new ECDH();
var b = new ECDH();
@@ -135,18 +134,20 @@ namespace Test
}
});
var wh = new Warehouse();
// Create stores to keep objects.
var system = await Warehouse.Put("sys", new MemoryStore());
var server = await Warehouse.Put("sys/server", new DistributedServer() { Membership = membership });
var system = await wh.Put("sys", new MemoryStore());
var server = await wh.Put("sys/server", new DistributedServer() { Membership = membership });
var web = await Warehouse.Put("sys/web", new HTTPServer() { Port = 8088 });
var web = await wh.Put("sys/web", new HTTPServer() { Port = 8088 });
var service = await Warehouse.Put("sys/service", new MyService());
var res1 = await Warehouse.Put("sys/service/r1", new MyResource() { Description = "Testing 1", CategoryId = 10 });
var res2 = await Warehouse.Put("sys/service/r2", new MyResource() { Description = "Testing 2", CategoryId = 11 });
var res3 = await Warehouse.Put("sys/service/c1", new MyChildResource() { ChildName = "Child 1", Description = "Child Testing 3", CategoryId = 12 });
var res4 = await Warehouse.Put("sys/service/c2", new MyChildResource() { ChildName = "Child 2 Destroy", Description = "Testing Destroy Handler", CategoryId = 12 });
var service = await wh.Put("sys/service", new MyService());
var res1 = await wh.Put("sys/service/r1", new MyResource() { Description = "Testing 1", CategoryId = 10 });
var res2 = await wh.Put("sys/service/r2", new MyResource() { Description = "Testing 2", CategoryId = 11 });
var res3 = await wh.Put("sys/service/c1", new MyChildResource() { ChildName = "Child 1", Description = "Child Testing 3", CategoryId = 12 });
var res4 = await wh.Put("sys/service/c2", new MyChildResource() { ChildName = "Child 2 Destroy", Description = "Testing Destroy Handler", CategoryId = 12 });
//TestSerialization(res1);
@@ -174,7 +175,7 @@ namespace Test
sender.Send("Hello");
});
await Warehouse.Open();
await wh.Open();
// Start testing
TestClient(service);
@@ -200,7 +201,7 @@ namespace Test
{
var con = await Warehouse.Get<DistributedConnection>("iip://localhost", new DistributedConnectionConfig
var con = await Warehouse.Default.Get<DistributedConnection>("iip://localhost", new DistributedConnectionConfig
{
AutoReconnect = true,
Username = "admin",