2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-03-31 18:38:22 +00:00

renaming 2

This commit is contained in:
2026-03-17 22:15:43 +03:00
parent 9d936c0812
commit e22e0d952d
88 changed files with 1685 additions and 1866 deletions

View File

@@ -27,7 +27,7 @@ SOFTWARE.
using Esiur.AspNetCore; using Esiur.AspNetCore;
using Esiur.AspNetCore.Example; using Esiur.AspNetCore.Example;
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP; using Esiur.Net.EP;
using Esiur.Net.Sockets; using Esiur.Net.Sockets;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Stores; using Esiur.Stores;

View File

@@ -24,8 +24,8 @@ SOFTWARE.
*/ */
using Esiur.Net.IIP;
using Esiur.Net.Sockets; using Esiur.Net.Sockets;
using Esiur.Protocol;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@@ -35,7 +35,7 @@ namespace Esiur.AspNetCore
{ {
public class EsiurMiddleware public class EsiurMiddleware
{ {
readonly DistributedServer server; readonly EpServer server;
readonly RequestDelegate next; readonly RequestDelegate next;
readonly ILoggerFactory loggerFactory; readonly ILoggerFactory loggerFactory;
@@ -44,13 +44,13 @@ namespace Esiur.AspNetCore
var buffer = new ArraySegment<byte>(new byte[10240]); var buffer = new ArraySegment<byte>(new byte[10240]);
if (context.WebSockets.IsWebSocketRequest if (context.WebSockets.IsWebSocketRequest
&& context.WebSockets.WebSocketRequestedProtocols.Contains("iip")) && context.WebSockets.WebSocketRequestedProtocols.Contains("EP"))
{ {
var webSocket = await context.WebSockets.AcceptWebSocketAsync("iip"); var webSocket = await context.WebSockets.AcceptWebSocketAsync("EP");
var socket = new FrameworkWebSocket(webSocket); var socket = new FrameworkWebSocket(webSocket);
var iipConnection = new DistributedConnection(); var EPConnection = new EpConnection();
server.Add(iipConnection); server.Add(EPConnection);
iipConnection.Assign(socket); EPConnection.Assign(socket);
socket.Begin(); socket.Begin();
// @TODO: Change this // @TODO: Change this

View File

@@ -24,12 +24,13 @@ SOFTWARE.
*/ */
using Esiur.Net.IIP;
using Esiur.Protocol;
namespace Esiur.AspNetCore namespace Esiur.AspNetCore
{ {
public class EsiurOptions public class EsiurOptions
{ {
public required DistributedServer Server { get; set; } public required EpServer Server { get; set; }
} }
} }

View File

@@ -46,6 +46,6 @@ To access the shell
Now you can simply test the running service typing Now you can simply test the running service typing
```javascript ```javascript
let x = await wh.get("iip://localhost:8080/sys/service", {secure: false}); let x = await wh.get("EP://localhost:8080/sys/service", {secure: false});
await x.Hello(); await x.Hello();
``` ```

View File

@@ -47,7 +47,7 @@ if (args.Length > 0)
{ {
try try
{ {
var path = Esiur.Proxy.TemplateGenerator.GetTemplate(url, o.Dir, false, o.Username, o.Password, o.AsyncSetters); var path = Esiur.Proxy.TypeDefGenerator.GetTemplate(url, o.Dir, false, o.Username, o.Password, o.AsyncSetters);
Console.WriteLine($"Generated successfully: {path}"); Console.WriteLine($"Generated successfully: {path}");
} }
catch (Exception ex) catch (Exception ex)
@@ -83,7 +83,7 @@ static void PrintHelp()
Console.WriteLine("Usage: <command> [arguments]"); Console.WriteLine("Usage: <command> [arguments]");
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine("Available commands:"); Console.WriteLine("Available commands:");
Console.WriteLine("\tget-template\tGet a template from an IIP link."); Console.WriteLine("\tget-template\tGet a template from an EP link.");
Console.WriteLine("\tversion\t\tPrint Esiur version."); Console.WriteLine("\tversion\t\tPrint Esiur version.");
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine("Global options:"); Console.WriteLine("Global options:");

View File

@@ -2,7 +2,7 @@
"profiles": { "profiles": {
"Esiur.CLI": { "Esiur.CLI": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "get-template iip://phase.delta.iq/sys/phase --dir c:\\temp\\an" "commandLineArgs": "get-template EP://phase.delta.iq/sys/phase --dir c:\\temp\\an"
} }
} }
} }

View File

@@ -9,7 +9,7 @@ A command-line utility to generate
# Usage # Usage
``` ```
Available commands: Available commands:
get-template Get a template from an IIP link. get-template Get a template from an EP link.
version Print Esiur version. version Print Esiur version.
Global options: Global options:
@@ -23,7 +23,7 @@ Global options:
## Example ## Example
``` ```
dotnet run esiur get-template iip://localhost/sys/service dotnet run esiur get-template EP://localhost/sys/service
``` ```

View File

@@ -1,7 +1,7 @@
using Esiur.Examples.StandaloneWebServerDemo; using Esiur.Examples.StandaloneWebServerDemo;
using Esiur.Net.HTTP; using Esiur.Net.HTTP;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Stores; using Esiur.Stores;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
@@ -18,7 +18,7 @@ internal class Program
// Create a store to keep objects. // Create a store to keep objects.
var system = await wh.Put("sys", new MemoryStore()); var system = await wh.Put("sys", new MemoryStore());
// Create a distibuted server // Create a distibuted server
var esiurServer = await wh.Put("sys/server", new DistributedServer()); var esiurServer = await wh.Put("sys/server", new EpServer());
// Add your object to the store // Add your object to the store
var service = await wh.Put("sys/demo", new Demo()); var service = await wh.Put("sys/demo", new Demo());

View File

@@ -1,7 +1,7 @@
async function init() { async function init() {
try { try {
connection = await wh.get(`iip://${window.location.hostname}`, { connection = await wh.get(`EP://${window.location.hostname}`, {
autoReconnect: true autoReconnect: true
}); });

View File

@@ -34,7 +34,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
using System.Reflection; using System.Reflection;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using System.Collections; using System.Collections;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Stores.EntityCore; namespace Esiur.Stores.EntityCore;
public class EntityStore : IStore public class EntityStore : IStore
@@ -179,7 +179,7 @@ public class EntityStore : IStore
//throw new NotImplementedException(); //throw new NotImplementedException();
} }
public bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime) public bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime)
{ {
return true; return true;
//throw new NotImplementedException(); //throw new NotImplementedException();
@@ -216,7 +216,7 @@ public class EntityStore : IStore
throw new NotImplementedException(); throw new NotImplementedException();
} }
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate) public AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -35,7 +35,7 @@ using System.Threading.Tasks;
using System.Linq; using System.Linq;
using Esiur.Security.Permissions; using Esiur.Security.Permissions;
using Esiur.Proxy; using Esiur.Proxy;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Stores.MongoDB; namespace Esiur.Stores.MongoDB;
@@ -342,7 +342,7 @@ public class MongoDBStore : IStore
var parents = new BsonArray(); var parents = new BsonArray();
var children = new BsonArray(); var children = new BsonArray();
var schema = resource.Instance.Schema; var typeDef = resource.Instance.Definition;
// setup attributes // setup attributes
resource.Instance.Variables["children"] = new string[0]; resource.Instance.Variables["children"] = new string[0];
@@ -381,7 +381,7 @@ public class MongoDBStore : IStore
var values = new BsonDocument(); var values = new BsonDocument();
foreach (var pt in schema.Properties) foreach (var pt in typeDef.Properties)
{ {
var rt = pt.PropertyInfo.GetValue(resource, null); var rt = pt.PropertyInfo.GetValue(resource, null);
@@ -594,7 +594,7 @@ public class MongoDBStore : IStore
var parents = new BsonArray(); var parents = new BsonArray();
var children = new BsonArray(); var children = new BsonArray();
var schema = resource.Instance.Schema; var typeDef = resource.Instance.Definition;
//foreach (IResource c in resource.Instance.Children) //foreach (IResource c in resource.Instance.Children)
// children.Add(c.Instance.Link); // children.Add(c.Instance.Link);
@@ -607,7 +607,7 @@ public class MongoDBStore : IStore
var values = new BsonDocument(); var values = new BsonDocument();
foreach (var pt in schema.Properties) foreach (var pt in typeDef.Properties)
{ {
/* /*
#if NETSTANDARD1_5 #if NETSTANDARD1_5
@@ -728,11 +728,11 @@ public class MongoDBStore : IStore
return reply; return reply;
} }
AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecordByAge(IResource resource, ulong fromAge, ulong toAge) AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecordByAge(IResource resource, ulong fromAge, ulong toAge)
{ {
var properties = resource.Instance.Schema.Properties.Where(x => x.Recordable).ToList(); var properties = resource.Instance.Definition.Properties.Where(x => x.HasHistory).ToList();
var reply = new AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>>(); var reply = new AsyncReply<KeyList<PropertyDef, PropertyValue[]>>();
AsyncBag<PropertyValue[]> bag = new AsyncBag<PropertyValue[]>(); AsyncBag<PropertyValue[]> bag = new AsyncBag<PropertyValue[]>();
@@ -743,7 +743,7 @@ public class MongoDBStore : IStore
bag.Then(x => bag.Then(x =>
{ {
var list = new KeyList<PropertyDefinition, PropertyValue[]>(); var list = new KeyList<PropertyDef, PropertyValue[]>();
for (var i = 0; i < x.Length; i++) for (var i = 0; i < x.Length; i++)
list.Add(properties[i], x[i]); list.Add(properties[i], x[i]);
@@ -754,11 +754,11 @@ public class MongoDBStore : IStore
return reply; return reply;
} }
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate) public AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{ {
var properties = resource.Instance.Schema.Properties.Where(x => x.Recordable).ToList(); var properties = resource.Instance.Definition.Properties.Where(x => x.HasHistory).ToList();
var reply = new AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>>(); var reply = new AsyncReply<KeyList<PropertyDef, PropertyValue[]>>();
AsyncBag<PropertyValue[]> bag = new AsyncBag<PropertyValue[]>(); AsyncBag<PropertyValue[]> bag = new AsyncBag<PropertyValue[]>();
@@ -769,7 +769,7 @@ public class MongoDBStore : IStore
bag.Then(x => bag.Then(x =>
{ {
var list = new KeyList<PropertyDefinition, PropertyValue[]>(); var list = new KeyList<PropertyDef, PropertyValue[]>();
for (var i = 0; i < x.Length; i++) for (var i = 0; i < x.Length; i++)
list.Add(properties[i], x[i]); list.Add(properties[i], x[i]);
@@ -780,7 +780,7 @@ public class MongoDBStore : IStore
return reply; return reply;
} }
public bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime) public bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime)
{ {
if (resource == this) if (resource == this)
@@ -790,7 +790,7 @@ public class MongoDBStore : IStore
var filter = Builders<BsonDocument>.Filter.Eq("_id", new BsonObjectId(new ObjectId(objectId))); var filter = Builders<BsonDocument>.Filter.Eq("_id", new BsonObjectId(new ObjectId(objectId)));
var update = Builders<BsonDocument>.Update var update = Builders<BsonDocument>.Update
.Set("values." + propertyName, new BsonDocument { { "age", BsonValue.Create(age) }, .Set("values." + propertyDef.Name, new BsonDocument { { "age", BsonValue.Create(age) },
{ "modification", dateTime }, { "modification", dateTime },
{ "value", Compose(value) } }); { "value", Compose(value) } });

View File

@@ -1,4 +1,4 @@
using Esiur.Net.IIP; using Esiur.Protocol;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -36,10 +36,10 @@ namespace Esiur.Core
Connection.SendWarning(CallbackId, level, message); Connection.SendWarning(CallbackId, level, message);
} }
public DistributedConnection Connection { get; internal set; } public EpConnection Connection { get; internal set; }
internal InvocationContext(DistributedConnection connection, uint callbackId) internal InvocationContext(EpConnection connection, uint callbackId)
{ {
Connection = connection; Connection = connection;
CallbackId = callbackId; CallbackId = callbackId;

View File

@@ -25,12 +25,12 @@ SOFTWARE.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Resource; using Esiur.Resource;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Collections; using System.Collections;
using Esiur.Protocol;
namespace Esiur.Data; namespace Esiur.Data;
@@ -39,9 +39,9 @@ namespace Esiur.Data;
public static class Codec public static class Codec
{ {
//delegate AsyncReply AsyncParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence); //delegate AsyncReply AsyncParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence);
delegate object AsyncParser(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence); delegate object AsyncParser(ParsedTDU tdu, EpConnection connection, uint[] requestSequence);
delegate object SyncParser(ParsedTDU tdu, Warehouse warehouse); delegate object SyncParser(ParsedTDU tdu, Warehouse warehouse);
static AsyncParser[][] FixedAsyncParsers = new AsyncParser[][] static AsyncParser[][] FixedAsyncParsers = new AsyncParser[][]
@@ -189,10 +189,10 @@ public static class Codec
/// <param name="data">Bytes array</param> /// <param name="data">Bytes array</param>
/// <param name="offset">Zero-indexed offset.</param> /// <param name="offset">Zero-indexed offset.</param>
/// <param name="size">Output the number of bytes parsed</param> /// <param name="size">Output the number of bytes parsed</param>
/// <param name="connection">DistributedConnection is required in case a structure in the array holds items at the other end.</param> /// <param name="connection">EpConnection is required in case a structure in the array holds items at the other end.</param>
/// <param name="dataType">DataType, in case the data is not prepended with DataType</param> /// <param name="dataType">DataType, in case the data is not prepended with DataType</param>
/// <returns>Value</returns> /// <returns>Value</returns>
public static (uint, object) ParseAsync(byte[] data, uint offset, DistributedConnection connection, uint[] requestSequence) public static (uint, object) ParseAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)
{ {
var tdu = ParsedTDU.Parse(data, offset, (uint)data.Length); var tdu = ParsedTDU.Parse(data, offset, (uint)data.Length);
@@ -219,7 +219,7 @@ public static class Codec
} }
} }
public static (uint, object) ParseAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static (uint, object) ParseAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
if (tdu.Class == TDUClass.Invalid) if (tdu.Class == TDUClass.Invalid)
throw new NullReferenceException("DataType can't be parsed."); throw new NullReferenceException("DataType can't be parsed.");
@@ -293,21 +293,21 @@ public static class Codec
/// Check if a resource is local to a given connection. /// Check if a resource is local to a given connection.
/// </summary> /// </summary>
/// <param name="resource">Resource to check.</param> /// <param name="resource">Resource to check.</param>
/// <param name="connection">DistributedConnection to check if the resource is local to it.</param> /// <param name="connection">EpConnection to check if the resource is local to it.</param>
/// <returns>True, if the resource owner is the given connection, otherwise False.</returns> /// <returns>True, if the resource owner is the given connection, otherwise False.</returns>
public static bool IsLocalResource(IResource resource, DistributedConnection connection) public static bool IsLocalResource(IResource resource, EpConnection connection)
{ {
if (resource == null) if (resource == null)
throw new NullReferenceException("Resource is null."); throw new NullReferenceException("Resource is null.");
if (resource is DistributedResource) if (resource is EpResource)
if (((DistributedResource)(resource)).DistributedResourceConnection == connection) if (((EpResource)(resource)).DistributedResourceConnection == connection)
return true; return true;
return false; return false;
} }
public delegate TDU Composer(object value, Warehouse warehouse, DistributedConnection connection); public delegate TDU Composer(object value, Warehouse warehouse, EpConnection connection);
public static Dictionary<Type, Composer> Composers = new Dictionary<Type, Composer>() public static Dictionary<Type, Composer> Composers = new Dictionary<Type, Composer>()
{ {
@@ -382,7 +382,7 @@ public static class Codec
internal static TDU internal static TDU
ComposeInternal(object valueOrSource, Warehouse warehouse, DistributedConnection connection) ComposeInternal(object valueOrSource, Warehouse warehouse, EpConnection connection)
{ {
if (valueOrSource == null) if (valueOrSource == null)
return new TDU(TDUIdentifier.Null, null, 0); return new TDU(TDUIdentifier.Null, null, 0);
@@ -400,9 +400,9 @@ public static class Codec
else if (genericType == typeof(Func<>)) else if (genericType == typeof(Func<>))
{ {
var args = genericType.GetGenericArguments(); var args = genericType.GetGenericArguments();
if (args.Length == 2 && args[0] == typeof(DistributedConnection)) if (args.Length == 2 && args[0] == typeof(EpConnection))
{ {
//Func<DistributedConnection, DistributedConnection> a; //Func<EpConnection, EpConnection> a;
//a.Invoke() //a.Invoke()
} }
} }
@@ -497,10 +497,10 @@ public static class Codec
/// Compose a variable /// Compose a variable
/// </summary> /// </summary>
/// <param name="value">Value to compose.</param> /// <param name="value">Value to compose.</param>
/// <param name="connection">DistributedConnection is required to check locality.</param> /// <param name="connection">EpConnection is required to check locality.</param>
/// <param name="prependType">If True, prepend the DataType at the beginning of the output.</param> /// <param name="prependType">If True, prepend the DataType at the beginning of the output.</param>
/// <returns>Array of bytes in the network byte order.</returns> /// <returns>Array of bytes in the network byte order.</returns>
public static byte[] Compose(object valueOrSource, Warehouse warehouse, DistributedConnection connection)//, bool prependType = true) public static byte[] Compose(object valueOrSource, Warehouse warehouse, EpConnection connection)//, bool prependType = true)
{ {
var tdu = ComposeInternal(valueOrSource, warehouse, connection); var tdu = ComposeInternal(valueOrSource, warehouse, connection);
return tdu.Composed; return tdu.Composed;

View File

@@ -26,8 +26,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Esiur.Net.IIP;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;

View File

@@ -1,5 +1,5 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP; using Esiur.Net.EP;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -14,115 +14,115 @@ namespace Esiur.Data;
public static class DataDeserializer public static class DataDeserializer
{ {
public static AsyncReply NullParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply NullParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply(null); return new AsyncReply(null);
} }
public static AsyncReply BooleanTrueParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply BooleanTrueParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<bool>(true); return new AsyncReply<bool>(true);
} }
public static AsyncReply BooleanFalseParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply BooleanFalseParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<bool>(false); return new AsyncReply<bool>(false);
} }
public static AsyncReply NotModifiedParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply NotModifiedParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<NotModified>(new NotModified()); return new AsyncReply<NotModified>(new NotModified());
} }
public static AsyncReply ByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply ByteParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<byte>(data[offset]); return new AsyncReply<byte>(data[offset]);
} }
public static AsyncReply SByteParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply SByteParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<sbyte>((sbyte)data[offset]); return new AsyncReply<sbyte>((sbyte)data[offset]);
} }
public static unsafe AsyncReply Char16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Char16Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<char>(*(char*)ptr); return new AsyncReply<char>(*(char*)ptr);
} }
public static AsyncReply Char8Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply Char8Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<char>((char)data[offset]); return new AsyncReply<char>((char)data[offset]);
} }
public static unsafe AsyncReply Int16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Int16Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<short>(*(short*)ptr); return new AsyncReply<short>(*(short*)ptr);
} }
public static unsafe AsyncReply UInt16Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply UInt16Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<ushort>(*(ushort*)ptr); return new AsyncReply<ushort>(*(ushort*)ptr);
} }
public static unsafe AsyncReply Int32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Int32Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<int>(*(int*)ptr); return new AsyncReply<int>(*(int*)ptr);
} }
public static unsafe AsyncReply UInt32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply UInt32Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<uint>(*(uint*)ptr); return new AsyncReply<uint>(*(uint*)ptr);
} }
public static unsafe AsyncReply Float32Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Float32Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<float>(*(float*)ptr); return new AsyncReply<float>(*(float*)ptr);
} }
public static unsafe AsyncReply Float64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Float64Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<double>(*(double*)ptr); return new AsyncReply<double>(*(double*)ptr);
} }
public static unsafe AsyncReply Float128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Float128Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<decimal>(*(decimal*)ptr); return new AsyncReply<decimal>(*(decimal*)ptr);
} }
public static unsafe AsyncReply Int128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Int128Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<decimal>(*(decimal*)ptr); return new AsyncReply<decimal>(*(decimal*)ptr);
} }
public static unsafe AsyncReply UInt128Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply UInt128Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<decimal>(*(decimal*)ptr); return new AsyncReply<decimal>(*(decimal*)ptr);
} }
public static unsafe AsyncReply Int64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply Int64Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<long>(*(long*)ptr); return new AsyncReply<long>(*(long*)ptr);
} }
public static unsafe AsyncReply UInt64Parser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply UInt64Parser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<ulong>(*(ulong*)ptr); return new AsyncReply<ulong>(*(ulong*)ptr);
} }
public static unsafe AsyncReply DateTimeParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply DateTimeParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return new AsyncReply<DateTime>(new DateTime(*(long*)ptr, DateTimeKind.Utc)); return new AsyncReply<DateTime>(new DateTime(*(long*)ptr, DateTimeKind.Utc));
@@ -130,30 +130,30 @@ public static class DataDeserializer
} }
public static unsafe AsyncReply ResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply ResourceParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return connection.Fetch(*(uint*)ptr, requestSequence); return connection.Fetch(*(uint*)ptr, requestSequence);
} }
public static unsafe AsyncReply LocalResourceParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply LocalResourceParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &data[offset]) fixed (byte* ptr = &data[offset])
return Warehouse.GetById(*(uint*)ptr); return Warehouse.GetById(*(uint*)ptr);
} }
public static unsafe AsyncReply RawDataParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply RawDataParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<byte[]>(data.Clip(offset, length)); return new AsyncReply<byte[]>(data.Clip(offset, length));
} }
public static unsafe AsyncReply StringParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply StringParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
return new AsyncReply<string>(data.GetString(offset, length)); return new AsyncReply<string>(data.GetString(offset, length));
} }
public static unsafe AsyncReply RecordParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply RecordParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var reply = new AsyncReply<IRecord>(); var reply = new AsyncReply<IRecord>();
@@ -229,12 +229,12 @@ public static class DataDeserializer
return reply; return reply;
} }
public static unsafe AsyncReply ConstantParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply ConstantParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public static unsafe AsyncReply EnumParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply EnumParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var classId = data.GetUUID(offset); var classId = data.GetUUID(offset);
@@ -262,7 +262,7 @@ public static class DataDeserializer
public static AsyncReply RecordListParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply RecordListParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<IRecord>(); var rt = new AsyncBag<IRecord>();
@@ -286,7 +286,7 @@ public static class DataDeserializer
return rt; return rt;
} }
public static AsyncReply ResourceListParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply ResourceListParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<IResource>(); var rt = new AsyncBag<IResource>();
@@ -311,7 +311,7 @@ public static class DataDeserializer
} }
public static AsyncBag<object> ListParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncBag<object> ListParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<object>(); var rt = new AsyncBag<object>();
@@ -335,7 +335,7 @@ public static class DataDeserializer
return rt; return rt;
} }
public static AsyncReply TypedMapParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TypedMapParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
// get key type // get key type
var (keyCs, keyRepType) = RepresentationType.Parse(data, offset); var (keyCs, keyRepType) = RepresentationType.Parse(data, offset);
@@ -384,7 +384,7 @@ public static class DataDeserializer
} }
public static AsyncReply TupleParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TupleParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var results = new AsyncBag<object>(); var results = new AsyncBag<object>();
var rt = new AsyncReply(); var rt = new AsyncReply();
@@ -443,7 +443,7 @@ public static class DataDeserializer
return rt; return rt;
} }
public static AsyncReply TypedListParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TypedListParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<object>(); var rt = new AsyncBag<object>();
@@ -478,7 +478,7 @@ public static class DataDeserializer
} }
public static AsyncBag<PropertyValue> PropertyValueArrayParser(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)//, bool ageIncluded = true) public static AsyncBag<PropertyValue> PropertyValueArrayParser(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
{ {
var rt = new AsyncBag<PropertyValue>(); var rt = new AsyncBag<PropertyValue>();
@@ -499,7 +499,7 @@ public static class DataDeserializer
} }
public static (uint, AsyncReply<PropertyValue>) PropertyValueParser(byte[] data, uint offset, DistributedConnection connection, uint[] requestSequence)//, bool ageIncluded = true) public static (uint, AsyncReply<PropertyValue>) PropertyValueParser(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
{ {
var reply = new AsyncReply<PropertyValue>(); var reply = new AsyncReply<PropertyValue>();
@@ -520,7 +520,7 @@ public static class DataDeserializer
return (16 + valueSize, reply); return (16 + valueSize, reply);
} }
public static AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> HistoryParser(byte[] data, uint offset, uint length, IResource resource, DistributedConnection connection, uint[] requestSequence) public static AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> HistoryParser(byte[] data, uint offset, uint length, IResource resource, EpConnection connection, uint[] requestSequence)
{ {
//var count = (int)toAge - (int)fromAge; //var count = (int)toAge - (int)fromAge;

View File

@@ -1,9 +1,9 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.GVWIE; using Esiur.Data.GVWIE;
using Esiur.Data.Schema; using Esiur.Data.Types;
using Esiur.Misc; using Esiur.Misc;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using System; using System;
@@ -17,7 +17,7 @@ namespace Esiur.Data;
public static class DataDeserializer public static class DataDeserializer
{ {
public static object NullParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object NullParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return null; return null;
} }
@@ -27,7 +27,7 @@ public static class DataDeserializer
return null; return null;
} }
public static object BooleanTrueParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object BooleanTrueParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return true; return true;
} }
@@ -37,7 +37,7 @@ public static class DataDeserializer
return true; return true;
} }
public static object BooleanFalseParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object BooleanFalseParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return false; return false;
} }
@@ -47,7 +47,7 @@ public static class DataDeserializer
return false; return false;
} }
public static object NotModifiedParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object NotModifiedParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return NotModified.Default; return NotModified.Default;
} }
@@ -57,7 +57,7 @@ public static class DataDeserializer
return NotModified.Default; return NotModified.Default;
} }
public static object UInt8ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object UInt8ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return tdu.Data[tdu.Offset]; return tdu.Data[tdu.Offset];
} }
@@ -66,7 +66,7 @@ public static class DataDeserializer
return tdu.Data[tdu.Offset]; return tdu.Data[tdu.Offset];
} }
public static object Int8ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object Int8ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return (sbyte)tdu.Data[tdu.Offset]; return (sbyte)tdu.Data[tdu.Offset];
} }
@@ -75,7 +75,7 @@ public static class DataDeserializer
return (sbyte)tdu.Data[tdu.Offset]; return (sbyte)tdu.Data[tdu.Offset];
} }
public static unsafe object Char16ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Char16ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(char*)ptr; return *(char*)ptr;
@@ -87,7 +87,7 @@ public static class DataDeserializer
return *(char*)ptr; return *(char*)ptr;
} }
public static object Char8ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object Char8ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return (char)tdu.Data[tdu.Offset]; return (char)tdu.Data[tdu.Offset];
} }
@@ -98,7 +98,7 @@ public static class DataDeserializer
} }
public static unsafe object Int16ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Int16ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(short*)ptr; return *(short*)ptr;
@@ -110,7 +110,7 @@ public static class DataDeserializer
return *(short*)ptr; return *(short*)ptr;
} }
public static unsafe object UInt16ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object UInt16ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(ushort*)ptr; return *(ushort*)ptr;
@@ -122,7 +122,7 @@ public static class DataDeserializer
return *(ushort*)ptr; return *(ushort*)ptr;
} }
public static unsafe object Int32ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Int32ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(int*)ptr; return *(int*)ptr;
@@ -134,7 +134,7 @@ public static class DataDeserializer
return *(int*)ptr; return *(int*)ptr;
} }
public static unsafe object UInt32ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object UInt32ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(uint*)ptr; return *(uint*)ptr;
@@ -147,7 +147,7 @@ public static class DataDeserializer
} }
public static unsafe object Float32ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Float32ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(float*)ptr; return *(float*)ptr;
@@ -159,7 +159,7 @@ public static class DataDeserializer
return *(float*)ptr; return *(float*)ptr;
} }
public static unsafe object Float64ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Float64ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(double*)ptr; return *(double*)ptr;
@@ -172,7 +172,7 @@ public static class DataDeserializer
} }
public static unsafe object Decimal128ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Decimal128ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(decimal*)ptr; return *(decimal*)ptr;
@@ -184,7 +184,7 @@ public static class DataDeserializer
return *(decimal*)ptr; return *(decimal*)ptr;
} }
public static unsafe object UUIDParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object UUIDParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return new UUID(tdu.Data, tdu.Offset); return new UUID(tdu.Data, tdu.Offset);
} }
@@ -196,7 +196,7 @@ public static class DataDeserializer
public static unsafe object Int128ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Int128ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr1 = &tdu.Data[tdu.Offset]) fixed (byte* ptr1 = &tdu.Data[tdu.Offset])
fixed (byte* ptr2 = &tdu.Data[tdu.Offset + 8]) fixed (byte* ptr2 = &tdu.Data[tdu.Offset + 8])
@@ -210,7 +210,7 @@ public static class DataDeserializer
return new Int128(*(ulong*)ptr1, *(ulong*)ptr2); return new Int128(*(ulong*)ptr1, *(ulong*)ptr2);
} }
public static unsafe object UInt128ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object UInt128ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr1 = &tdu.Data[tdu.Offset]) fixed (byte* ptr1 = &tdu.Data[tdu.Offset])
fixed (byte* ptr2 = &tdu.Data[tdu.Offset + 8]) fixed (byte* ptr2 = &tdu.Data[tdu.Offset + 8])
@@ -224,7 +224,7 @@ public static class DataDeserializer
return new UInt128(*(ulong*)ptr1, *(ulong*)ptr2); return new UInt128(*(ulong*)ptr1, *(ulong*)ptr2);
} }
public static unsafe object Int64ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object Int64ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(long*)ptr; return *(long*)ptr;
@@ -237,7 +237,7 @@ public static class DataDeserializer
} }
public static unsafe object UInt64ParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object UInt64ParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return *(ulong*)ptr; return *(ulong*)ptr;
@@ -250,7 +250,7 @@ public static class DataDeserializer
} }
public static unsafe object DateTimeParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object DateTimeParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
return new DateTime(*(long*)ptr, DateTimeKind.Utc); return new DateTime(*(long*)ptr, DateTimeKind.Utc);
@@ -264,7 +264,7 @@ public static class DataDeserializer
} }
public static object ResourceLinkParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static object ResourceLinkParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var link = tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength); var link = tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength);
if (connection == null) if (connection == null)
@@ -283,7 +283,7 @@ public static class DataDeserializer
return new ResourceLink(link); return new ResourceLink(link);
} }
public static unsafe object ResourceParser8Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object ResourceParser8Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
if (connection == null) if (connection == null)
return new ResourceId(false, tdu.Data[tdu.Offset]); return new ResourceId(false, tdu.Data[tdu.Offset]);
@@ -296,7 +296,7 @@ public static class DataDeserializer
return new ResourceId(false, tdu.Data[tdu.Offset]); return new ResourceId(false, tdu.Data[tdu.Offset]);
} }
public static unsafe object LocalResourceParser8Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object LocalResourceParser8Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
if (connection == null) if (connection == null)
return new ResourceId(true, tdu.Data[tdu.Offset]); return new ResourceId(true, tdu.Data[tdu.Offset]);
@@ -309,7 +309,7 @@ public static class DataDeserializer
return new ResourceId(true, tdu.Data[tdu.Offset]); return new ResourceId(true, tdu.Data[tdu.Offset]);
} }
public static unsafe object ResourceParser16Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object ResourceParser16Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
if (connection == null) if (connection == null)
@@ -325,7 +325,7 @@ public static class DataDeserializer
} }
public static unsafe object LocalResourceParser16Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object LocalResourceParser16Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
if (connection == null) if (connection == null)
@@ -340,7 +340,7 @@ public static class DataDeserializer
return new ResourceId(true, *(ushort*)ptr); return new ResourceId(true, *(ushort*)ptr);
} }
public static unsafe object ResourceParser32Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object ResourceParser32Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
if (connection == null) if (connection == null)
@@ -356,7 +356,7 @@ public static class DataDeserializer
} }
public static unsafe object LocalResourceParser32Async(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object LocalResourceParser32Async(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
fixed (byte* ptr = &tdu.Data[tdu.Offset]) fixed (byte* ptr = &tdu.Data[tdu.Offset])
if (connection == null) if (connection == null)
@@ -372,7 +372,7 @@ public static class DataDeserializer
} }
public static unsafe object RawDataParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object RawDataParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return tdu.Data.Clip(tdu.Offset, (uint)tdu.ContentLength); return tdu.Data.Clip(tdu.Offset, (uint)tdu.ContentLength);
} }
@@ -383,7 +383,7 @@ public static class DataDeserializer
} }
public static unsafe object StringParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object StringParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
return tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength); return tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength);
} }
@@ -393,10 +393,10 @@ public static class DataDeserializer
return tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength); return tdu.Data.GetString(tdu.Offset, (uint)tdu.ContentLength);
} }
public static unsafe object RecordParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object RecordParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var classId = tdu.Metadata.GetUUID(0); var typeId = tdu.Metadata.GetUUID(0);
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, var typeDef = connection.Instance.Warehouse.GetTypeDefById(typeId,
TypeDefKind.Record); TypeDefKind.Record);
var rt = new AsyncReply<IRecord>(); var rt = new AsyncReply<IRecord>();
@@ -410,9 +410,9 @@ public static class DataDeserializer
var length = tdu.ContentLength; var length = tdu.ContentLength;
var ends = offset + (uint)length; var ends = offset + (uint)length;
var initRecord = (TypeDef template) => var initRecord = (TypeDef typeDef) =>
{ {
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
{ {
current = ParsedTDU.Parse(tdu.Data, offset, ends); current = ParsedTDU.Parse(tdu.Data, offset, ends);
@@ -428,7 +428,7 @@ public static class DataDeserializer
} }
else if (current.Identifier == TDUIdentifier.TypeOfTarget) else if (current.Identifier == TDUIdentifier.TypeOfTarget)
{ {
var (idf, mt) = template.Properties[i].ValueType.GetMetadata(); var (idf, mt) = typeDef.Properties[i].ValueType.GetMetadata();
current.Class = TDUClass.Typed; current.Class = TDUClass.Typed;
current.Identifier = idf; current.Identifier = idf;
current.Metadata = mt; current.Metadata = mt;
@@ -454,16 +454,16 @@ public static class DataDeserializer
list.Then(results => list.Then(results =>
{ {
if (template.DefinedType != null) if (typeDef.DefinedType != null)
{ {
var record = Activator.CreateInstance(template.DefinedType) as IRecord; var record = Activator.CreateInstance(typeDef.DefinedType) as IRecord;
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
{ {
try try
{ {
var v = RuntimeCaster.Cast(results[i], template.Properties[i].PropertyInfo.PropertyType); var v = RuntimeCaster.Cast(results[i], typeDef.Properties[i].PropertyInfo.PropertyType);
template.Properties[i].PropertyInfo.SetValue(record, v); typeDef.Properties[i].PropertyInfo.SetValue(record, v);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -477,8 +477,8 @@ public static class DataDeserializer
{ {
var record = new Record(); var record = new Record();
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
record.Add(template.Properties[i].Name, results[i]); record.Add(typeDef.Properties[i].Name, results[i]);
rt.Trigger(record); rt.Trigger(record);
} }
@@ -492,14 +492,14 @@ public static class DataDeserializer
}; };
if (template != null) if (typeDef != null)
{ {
initRecord(template); initRecord(typeDef);
} }
else if (connection != null) else if (connection != null)
{ {
// try to get the template from the other end // try to get the TypeDef from the other end
connection.GetTemplate(classId).Then(tmp => connection.GetTypeDefById(typeId).Then(tmp =>
{ {
initRecord(tmp); initRecord(tmp);
}).Error(x => rt.TriggerError(x)); }).Error(x => rt.TriggerError(x));
@@ -512,86 +512,19 @@ public static class DataDeserializer
return rt; return rt;
//var classId = tdu.Metadata.GetUUID(0);
//var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
//var initRecord = (TypeSchema template) =>
//{
// ListParserAsync(tdu, connection, requestSequence).Then(r =>
// {
// var ar = (object[])r;
// if (template == null)
// {
// // @TODO: add parse if no template settings
// reply.TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TemplateNotFound,
// "Template not found for record."));
// }
// else if (template.DefinedType != null)
// {
// var record = Activator.CreateInstance(template.DefinedType) as IRecord;
// for (var i = 0; i < template.Properties.Length; i++)
// {
// try
// {
// //var v = Convert.ChangeType(ar[i], template.Properties[i].PropertyInfo.PropertyType);
// var v = RuntimeCaster.Cast(ar[i], template.Properties[i].PropertyInfo.PropertyType);
// template.Properties[i].PropertyInfo.SetValue(record, v);
// }
// catch (Exception ex)
// {
// Global.Log(ex);
// }
// }
// reply.Trigger(record);
// }
// else
// {
// var record = new Record();
// for (var i = 0; i < template.Properties.Length; i++)
// record.Add(template.Properties[i].Name, ar[i]);
// reply.Trigger(record);
// }
// });
//};
//if (template != null)
//{
// initRecord(template);
//}
//else if (connection != null)
//{
// // try to get the template from the other end
// connection.GetTemplate(classId).Then(tmp =>
// {
// initRecord(tmp);
// }).Error(x => reply.TriggerError(x));
//}
//else
//{
// initRecord(null);
//}
//return reply;
} }
public static unsafe object RecordParser(ParsedTDU tdu, Warehouse warehouse) public static unsafe object RecordParser(ParsedTDU tdu, Warehouse warehouse)
{ {
var classId = tdu.Metadata.GetUUID(0); var classId = tdu.Metadata.GetUUID(0);
var template = warehouse.GetTypeDefByClassId(classId, TypeDefKind.Record); var typeDef = warehouse.GetTypeDefById(classId, TypeDefKind.Record);
if (template == null) if (typeDef == null)
{ {
// @TODO: add parse if no template settings // @TODO: add parse if no TypeDef settings
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound, throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TypeDefNotFound,
"Template not found for record."); "TypeDef not found for record.");
} }
var list = new List<object>(); var list = new List<object>();
@@ -604,7 +537,7 @@ public static class DataDeserializer
var ends = offset + (uint)length; var ends = offset + (uint)length;
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
{ {
current = ParsedTDU.Parse(tdu.Data, offset, ends); current = ParsedTDU.Parse(tdu.Data, offset, ends);
@@ -620,7 +553,7 @@ public static class DataDeserializer
} }
else if (current.Identifier == TDUIdentifier.TypeOfTarget) else if (current.Identifier == TDUIdentifier.TypeOfTarget)
{ {
var (idf, mt) = template.Properties[i].ValueType.GetMetadata(); var (idf, mt) = typeDef.Properties[i].ValueType.GetMetadata();
current.Class = TDUClass.Typed; current.Class = TDUClass.Typed;
current.Identifier = idf; current.Identifier = idf;
current.Metadata = mt; current.Metadata = mt;
@@ -642,16 +575,16 @@ public static class DataDeserializer
} }
if (template.DefinedType != null) if (typeDef.DefinedType != null)
{ {
var record = Activator.CreateInstance(template.DefinedType) as IRecord; var record = Activator.CreateInstance(typeDef.DefinedType) as IRecord;
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
{ {
try try
{ {
var v = RuntimeCaster.Cast(list[i], template.Properties[i].PropertyInfo.PropertyType); var v = RuntimeCaster.Cast(list[i], typeDef.Properties[i].PropertyInfo.PropertyType);
template.Properties[i].PropertyInfo.SetValue(record, v); typeDef.Properties[i].PropertyInfo.SetValue(record, v);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -665,14 +598,14 @@ public static class DataDeserializer
{ {
var record = new Record(); var record = new Record();
for (var i = 0; i < template.Properties.Length; i++) for (var i = 0; i < typeDef.Properties.Length; i++)
record.Add(template.Properties[i].Name, list[i]); record.Add(typeDef.Properties[i].Name, list[i]);
return record; return record;
} }
} }
public static unsafe object ConstantParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe object ConstantParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -682,26 +615,26 @@ public static class DataDeserializer
throw new NotImplementedException(); throw new NotImplementedException();
} }
public static unsafe AsyncReply EnumParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static unsafe AsyncReply EnumParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var classId = tdu.Metadata.GetUUID(0); var typeId = tdu.Metadata.GetUUID(0);
var index = tdu.Data[tdu.Offset]; var index = tdu.Data[tdu.Offset];
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, var typeDef = connection.Instance.Warehouse.GetTypeDefById(typeId,
TypeDefKind.Enum); TypeDefKind.Enum);
if (template != null) if (typeDef != null)
{ {
return new AsyncReply(template.Constants[index].Value); return new AsyncReply(typeDef.Constants[index].Value);
} }
else else
{ {
var reply = new AsyncReply(); var reply = new AsyncReply();
connection.GetTemplate(classId).Then(tmp => connection.GetTypeDefById(typeId).Then(tmp =>
{ {
reply.Trigger(tmp.Constants[index].Value); reply.Trigger(tmp.Constants[index].Value);
}).Error(x => reply.TriggerError(x)); }).Error(x => reply.TriggerError(x));
@@ -713,25 +646,25 @@ public static class DataDeserializer
public static unsafe object EnumParser(ParsedTDU tdu, Warehouse warehouse) public static unsafe object EnumParser(ParsedTDU tdu, Warehouse warehouse)
{ {
var classId = tdu.Metadata.GetUUID(0); var typeId = tdu.Metadata.GetUUID(0);
var index = tdu.Data[tdu.Offset]; var index = tdu.Data[tdu.Offset];
var template = warehouse.GetTemplateByClassId(classId, TypeDefKind.Enum); var typeDef = warehouse.GetTypeDefById(typeId, TypeDefKind.Enum);
if (template != null) if (typeDef != null)
{ {
return template.Constants[index].Value; return typeDef.Constants[index].Value;
} }
else else
{ {
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound, throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TypeDefNotFound,
"Template not found for enum."); "TypeDef not found for enum.");
} }
} }
public static AsyncReply RecordListParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncReply RecordListParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<IRecord>(); var rt = new AsyncBag<IRecord>();
@@ -784,7 +717,7 @@ public static class DataDeserializer
return rt.ToArray(); return rt.ToArray();
} }
public static AsyncReply ResourceListParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncReply ResourceListParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncBag<IResource>(); var rt = new AsyncBag<IResource>();
@@ -838,7 +771,7 @@ public static class DataDeserializer
return rt.ToArray(); return rt.ToArray();
} }
public static AsyncBag<object> ListParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncBag<object> ListParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
//var rt = new AsyncBag<object>(); //var rt = new AsyncBag<object>();
@@ -990,7 +923,7 @@ public static class DataDeserializer
} }
public static AsyncReply TypedMapParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TypedMapParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncReply(); var rt = new AsyncReply();
@@ -1105,12 +1038,12 @@ public static class DataDeserializer
var enumType = tru.GetRuntimeType(warehouse); var enumType = tru.GetRuntimeType(warehouse);
var enums = Array.CreateInstance(enumType, (int)tdu.ContentLength); var enums = Array.CreateInstance(enumType, (int)tdu.ContentLength);
var enumTemplate = warehouse.GetTemplateByType(enumType); var enumTypeDef = warehouse.GetTypeDefByType(enumType);
for (var i = 0; i < (int)tdu.ContentLength; i++) for (var i = 0; i < (int)tdu.ContentLength; i++)
{ {
var index = tdu.Data[tdu.Offset + i]; var index = tdu.Data[tdu.Offset + i];
enums.SetValue(enumTemplate.Constants[index].Value, i); enums.SetValue(enumTypeDef.Constants[index].Value, i);
} }
return enums; return enums;
@@ -1202,7 +1135,7 @@ public static class DataDeserializer
} }
public static AsyncReply TupleParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TupleParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
var rt = new AsyncReply(); var rt = new AsyncReply();
@@ -1392,7 +1325,7 @@ public static class DataDeserializer
} }
public static AsyncReply TypedArrayParserAsync(ParsedTDU tdu, TRU tru, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TypedArrayParserAsync(ParsedTDU tdu, TRU tru, EpConnection connection, uint[] requestSequence)
{ {
switch (tru.Identifier) switch (tru.Identifier)
{ {
@@ -1419,13 +1352,13 @@ public static class DataDeserializer
var enumType = tru.GetRuntimeType(connection.Instance.Warehouse); var enumType = tru.GetRuntimeType(connection.Instance.Warehouse);
var rt = Array.CreateInstance(enumType, (int)tdu.ContentLength); var rt = Array.CreateInstance(enumType, (int)tdu.ContentLength);
var enumTemplate = connection.Instance.Warehouse.GetTemplateByType(enumType); var enumTypeDef = connection.Instance.Warehouse.GetTypeDefByType(enumType);
for (var i = 0; i < (int)tdu.ContentLength; i++) for (var i = 0; i < (int)tdu.ContentLength; i++)
{ {
var index = tdu.Data[tdu.Offset + i]; var index = tdu.Data[tdu.Offset + i];
rt.SetValue(Enum.ToObject(enumType, enumTemplate.Constants[index].Value), i); rt.SetValue(Enum.ToObject(enumType, enumTypeDef.Constants[index].Value), i);
} }
return new AsyncReply(rt); return new AsyncReply(rt);
@@ -1488,7 +1421,7 @@ public static class DataDeserializer
} }
public static AsyncReply TypedListParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence) public static AsyncReply TypedListParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
{ {
// get the type // get the type
var (hdrCs, tru) = TRU.Parse(tdu.Metadata, 0); var (hdrCs, tru) = TRU.Parse(tdu.Metadata, 0);
@@ -1573,7 +1506,7 @@ public static class DataDeserializer
return TypedArrayParser(tdu, tru, warehouse); return TypedArrayParser(tdu, tru, warehouse);
} }
public static AsyncBag<PropertyValue> PropertyValueArrayParserAsync(byte[] data, uint offset, uint length, DistributedConnection connection, uint[] requestSequence)//, bool ageIncluded = true) public static AsyncBag<PropertyValue> PropertyValueArrayParserAsync(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
{ {
var rt = new AsyncBag<PropertyValue>(); var rt = new AsyncBag<PropertyValue>();
@@ -1597,7 +1530,7 @@ public static class DataDeserializer
} }
public static (uint, AsyncReply<PropertyValue>) PropertyValueParserAsync(byte[] data, uint offset, DistributedConnection connection, uint[] requestSequence)//, bool ageIncluded = true) public static (uint, AsyncReply<PropertyValue>) PropertyValueParserAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
{ {
var reply = new AsyncReply<PropertyValue>(); var reply = new AsyncReply<PropertyValue>();
@@ -1625,13 +1558,13 @@ public static class DataDeserializer
return (16 + valueSize, reply); return (16 + valueSize, reply);
} }
public static AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> HistoryParserAsync(byte[] data, uint offset, uint length, IResource resource, DistributedConnection connection, uint[] requestSequence) public static AsyncReply<KeyList<PropertyDef, PropertyValue[]>> HistoryParserAsync(byte[] data, uint offset, uint length, IResource resource, EpConnection connection, uint[] requestSequence)
{ {
//var count = (int)toAge - (int)fromAge; //var count = (int)toAge - (int)fromAge;
var list = new KeyList<PropertyDefinition, PropertyValue[]>(); var list = new KeyList<PropertyDef, PropertyValue[]>();
var reply = new AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>>(); var reply = new AsyncReply<KeyList<PropertyDef, PropertyValue[]>>();
var bagOfBags = new AsyncBag<PropertyValue[]>(); var bagOfBags = new AsyncBag<PropertyValue[]>();
@@ -1639,7 +1572,7 @@ public static class DataDeserializer
while (offset < ends) while (offset < ends)
{ {
var index = data[offset++]; var index = data[offset++];
var pt = resource.Instance.Schema.GetPropertyDefByIndex(index); var pt = resource.Instance.Definition.GetPropertyDefByIndex(index);
list.Add(pt, null); list.Add(pt, null);
var cs = data.GetUInt32(offset, Endian.Little); var cs = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;

View File

@@ -1,7 +1,7 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Data.GVWIE; using Esiur.Data.GVWIE;
using Esiur.Data.Schema; using Esiur.Data.Types;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using System; using System;
@@ -17,7 +17,7 @@ public static class DataSerializer
{ {
public delegate byte[] Serializer(object value); public delegate byte[] Serializer(object value);
public static unsafe TDU Int32Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Int32Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (int)value; var v = (int)value;
@@ -44,7 +44,7 @@ public static class DataSerializer
} }
} }
public static unsafe TDU UInt32Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU UInt32Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (uint)value; var v = (uint)value;
@@ -73,7 +73,7 @@ public static class DataSerializer
} }
} }
public static unsafe TDU Int16Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Int16Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (short)value; var v = (short)value;
@@ -93,7 +93,7 @@ public static class DataSerializer
} }
} }
public static unsafe TDU UInt16Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU UInt16Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (ushort)value; var v = (ushort)value;
@@ -114,7 +114,7 @@ public static class DataSerializer
} }
public static unsafe TDU Float32Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Float32Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
float v = (float)value; float v = (float)value;
@@ -152,7 +152,7 @@ public static class DataSerializer
} }
public unsafe static TDU Float64Composer(object value, Warehouse warehouse, DistributedConnection connection) public unsafe static TDU Float64Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
double v = (double)value; double v = (double)value;
@@ -211,7 +211,7 @@ public static class DataSerializer
return new TDU(TDUIdentifier.Float64, rt, 8); return new TDU(TDUIdentifier.Float64, rt, 8);
} }
} }
public static unsafe TDU Int64Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Int64Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (long)value; var v = (long)value;
@@ -249,7 +249,7 @@ public static class DataSerializer
} }
} }
public static unsafe TDU UInt64Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU UInt64Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (ulong)value; var v = (ulong)value;
@@ -288,7 +288,7 @@ public static class DataSerializer
} }
public static unsafe TDU DateTimeComposer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU DateTimeComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = ((DateTime)value).ToUniversalTime().Ticks; var v = ((DateTime)value).ToUniversalTime().Ticks;
var rt = new byte[8]; var rt = new byte[8];
@@ -298,7 +298,7 @@ public static class DataSerializer
return new TDU(TDUIdentifier.DateTime, rt, 8); return new TDU(TDUIdentifier.DateTime, rt, 8);
} }
//public static unsafe TDU Decimal128Composer(object value, Warehouse warehouse, DistributedConnection connection) //public static unsafe TDU Decimal128Composer(object value, Warehouse warehouse, EpConnection connection)
//{ //{
// var v = (decimal)value; // var v = (decimal)value;
// var rt = new byte[16]; // var rt = new byte[16];
@@ -308,7 +308,7 @@ public static class DataSerializer
// return new TDU(TDUIdentifier.Decimal128, rt, 16); // return new TDU(TDUIdentifier.Decimal128, rt, 16);
//} //}
public static unsafe TDU Decimal128Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Decimal128Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (decimal)value; var v = (decimal)value;
@@ -381,14 +381,14 @@ public static class DataSerializer
} }
} }
public static TDU StringComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU StringComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var b = Encoding.UTF8.GetBytes((string)value); var b = Encoding.UTF8.GetBytes((string)value);
return new TDU(TDUIdentifier.String, b, (uint)b.Length); return new TDU(TDUIdentifier.String, b, (uint)b.Length);
} }
public static TDU ResourceLinkComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU ResourceLinkComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var b = Encoding.UTF8.GetBytes((ResourceLink)value); var b = Encoding.UTF8.GetBytes((ResourceLink)value);
@@ -396,7 +396,7 @@ public static class DataSerializer
} }
public static TDU EnumComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU EnumComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, null, 0); return new TDU(TDUIdentifier.Null, null, 0);
@@ -406,11 +406,11 @@ public static class DataSerializer
//if (warehouse == null) //if (warehouse == null)
// throw new Exception("Warehouse not set."); // throw new Exception("Warehouse not set.");
var template = warehouse.GetTemplateByType(value.GetType()); var typeDef = warehouse.GetTypeDefByType(value.GetType());
var intVal = Convert.ChangeType(value, (value as Enum).GetTypeCode()); var intVal = Convert.ChangeType(value, (value as Enum).GetTypeCode());
var ct = template.Constants.FirstOrDefault(x => x.Value.Equals(intVal)); var ct = typeDef.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
if (ct == null) if (ct == null)
return new TDU(TDUIdentifier.Null, null, 0); return new TDU(TDUIdentifier.Null, null, 0);
@@ -418,28 +418,28 @@ public static class DataSerializer
//return Codec.ComposeInternal(intVal, warehouse, connection); //return Codec.ComposeInternal(intVal, warehouse, connection);
return new TDU(TDUIdentifier.TypedEnum, return new TDU(TDUIdentifier.TypedEnum,
new byte[] { ct.Index }, 1, template.ClassId.Data); new byte[] { ct.Index }, 1, typeDef.Id.Data);
} }
public static TDU UInt8Composer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU UInt8Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
return new TDU(TDUIdentifier.UInt8, return new TDU(TDUIdentifier.UInt8,
new byte[] { (byte)value }, 1); new byte[] { (byte)value }, 1);
} }
public static TDU Int8Composer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU Int8Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
return new TDU(TDUIdentifier.Int8, return new TDU(TDUIdentifier.Int8,
new byte[] { (byte)(sbyte)value }, 1); new byte[] { (byte)(sbyte)value }, 1);
} }
public static TDU Char8Composer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU Char8Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
return new TDU(TDUIdentifier.Int8, return new TDU(TDUIdentifier.Int8,
new byte[] { (byte)(char)value }, 1); new byte[] { (byte)(char)value }, 1);
} }
public static unsafe TDU Char16Composer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU Char16Composer(object value, Warehouse warehouse, EpConnection connection)
{ {
var v = (char)value; var v = (char)value;
var rt = new byte[2]; var rt = new byte[2];
@@ -450,7 +450,7 @@ public static class DataSerializer
} }
public static TDU BoolComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU BoolComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if ((bool)value) if ((bool)value)
{ {
@@ -463,24 +463,24 @@ public static class DataSerializer
} }
public static TDU NotModifiedComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU NotModifiedComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
return new TDU(TDUIdentifier.NotModified, null, 0); return new TDU(TDUIdentifier.NotModified, null, 0);
} }
public static TDU RawDataComposerFromArray(object value, Warehouse warehouse, DistributedConnection connection) public static TDU RawDataComposerFromArray(object value, Warehouse warehouse, EpConnection connection)
{ {
var b = (byte[])value; var b = (byte[])value;
return new TDU(TDUIdentifier.RawData, b, (uint)b.Length); return new TDU(TDUIdentifier.RawData, b, (uint)b.Length);
} }
public static TDU RawDataComposerFromList(dynamic value, Warehouse warehouse, DistributedConnection connection) public static TDU RawDataComposerFromList(dynamic value, Warehouse warehouse, EpConnection connection)
{ {
var b = value as List<byte>; var b = value as List<byte>;
return new TDU(TDUIdentifier.RawData, b.ToArray(), (uint)b.Count); return new TDU(TDUIdentifier.RawData, b.ToArray(), (uint)b.Count);
} }
//public static (TDUIdentifier, byte[]) ListComposerFromArray(dynamic value, DistributedConnection connection) //public static (TDUIdentifier, byte[]) ListComposerFromArray(dynamic value, EpConnection connection)
//{ //{
// var rt = new List<byte>(); // var rt = new List<byte>();
// var array = (object[])value; // var array = (object[])value;
@@ -491,7 +491,7 @@ public static class DataSerializer
// return (TDUIdentifier.List, rt.ToArray()); // return (TDUIdentifier.List, rt.ToArray());
//} //}
public static TDU ListComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU ListComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var composed = DynamicArrayComposer((IEnumerable)value, warehouse, connection); var composed = DynamicArrayComposer((IEnumerable)value, warehouse, connection);
@@ -534,7 +534,7 @@ public static class DataSerializer
//return new TDU(TDUIdentifier.List, rt.ToArray(), (uint)rt.Count); //return new TDU(TDUIdentifier.List, rt.ToArray(), (uint)rt.Count);
} }
public static byte[] TypedArrayComposer(IEnumerable value, TRU tru, Warehouse warehouse, DistributedConnection connection) public static byte[] TypedArrayComposer(IEnumerable value, TRU tru, Warehouse warehouse, EpConnection connection)
{ {
byte[] composed; byte[] composed;
@@ -570,12 +570,12 @@ public static class DataSerializer
{ {
var rt = new List<byte>(); var rt = new List<byte>();
var template = warehouse.GetTemplateByType(tru.GetRuntimeType(warehouse)); var typeDef = warehouse.GetTypeDefByType(tru.GetRuntimeType(warehouse));
foreach (var v in value) foreach (var v in value)
{ {
var intVal = Convert.ChangeType(v, (v as Enum).GetTypeCode()); var intVal = Convert.ChangeType(v, (v as Enum).GetTypeCode());
var ct = template.Constants.FirstOrDefault(x => x.Value.Equals(intVal)); var ct = typeDef.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
if (ct == null) if (ct == null)
throw new Exception("Unknown Enum."); throw new Exception("Unknown Enum.");
rt.Add(ct.Index); rt.Add(ct.Index);
@@ -630,7 +630,7 @@ public static class DataSerializer
} }
public static TDU TypedListComposer(IEnumerable value, Type type, Warehouse warehouse, DistributedConnection connection) public static TDU TypedListComposer(IEnumerable value, Type type, Warehouse warehouse, EpConnection connection)
{ {
var tru = TRU.FromType(type); var tru = TRU.FromType(type);
@@ -644,7 +644,7 @@ public static class DataSerializer
return new TDU(TDUIdentifier.TypedList, composed, (uint)composed.Length, metadata); return new TDU(TDUIdentifier.TypedList, composed, (uint)composed.Length, metadata);
} }
//public static byte[] PropertyValueComposer(PropertyValue propertyValue, DistributedConnection connection)//, bool includeAge = true) //public static byte[] PropertyValueComposer(PropertyValue propertyValue, EpConnection connection)//, bool includeAge = true)
//{ //{
// var rt = new BinaryList(); // var rt = new BinaryList();
@@ -655,7 +655,7 @@ public static class DataSerializer
// .ToArray(); // .ToArray();
//} //}
public static TDU PropertyValueArrayComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU PropertyValueArrayComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 0); return new TDU(TDUIdentifier.Null, new byte[0], 0);
@@ -674,7 +674,7 @@ public static class DataSerializer
(uint)rt.Count); (uint)rt.Count);
} }
public static TDU TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection) public static TDU TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 0); return new TDU(TDUIdentifier.Null, new byte[0], 0);
@@ -712,7 +712,7 @@ public static class DataSerializer
//return new TDU(TDUIdentifier.TypedMap, rt.ToArray(), (uint)rt.Count, //return new TDU(TDUIdentifier.TypedMap, rt.ToArray(), (uint)rt.Count,
// ); // );
} }
public static TDU TypedDictionaryComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection) public static TDU TypedDictionaryComposer(object value, Type keyType, Type valueType, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
@@ -775,7 +775,7 @@ public static class DataSerializer
// DC.Combine(kt, 0, (uint)kt.Length, vt, 0, (uint)vt.Length)); // DC.Combine(kt, 0, (uint)kt.Length, vt, 0, (uint)vt.Length));
} }
public static byte[] DynamicArrayComposer(IEnumerable value, Warehouse warehouse, DistributedConnection connection) public static byte[] DynamicArrayComposer(IEnumerable value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return null; return null;
@@ -806,7 +806,7 @@ public static class DataSerializer
return rt.ToArray(); return rt.ToArray();
} }
public static TDU ResourceListComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU ResourceListComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 0); return new TDU(TDUIdentifier.Null, new byte[0], 0);
@@ -817,7 +817,7 @@ public static class DataSerializer
(uint)composed.Length); (uint)composed.Length);
} }
public static TDU RecordListComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU RecordListComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 0); return new TDU(TDUIdentifier.Null, new byte[0], 0);
@@ -829,7 +829,7 @@ public static class DataSerializer
} }
public static unsafe TDU ResourceComposer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU ResourceComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var resource = (IResource)value; var resource = (IResource)value;
@@ -840,7 +840,7 @@ public static class DataSerializer
if (Codec.IsLocalResource(resource, connection)) if (Codec.IsLocalResource(resource, connection))
{ {
var rid = (resource as DistributedResource).DistributedResourceInstanceId; var rid = (resource as EpResource).DistributedResourceInstanceId;
if (rid <= 0xFF) if (rid <= 0xFF)
return new TDU(TDUIdentifier.LocalResource8, new byte[] { (byte)rid }, 1); return new TDU(TDUIdentifier.LocalResource8, new byte[] { (byte)rid }, 1);
@@ -863,7 +863,6 @@ public static class DataSerializer
else else
{ {
//rt.Append((value as IResource).Instance.Template.ClassId, (value as IResource).Instance.Id);
connection.cache.Add(value as IResource, DateTime.UtcNow); connection.cache.Add(value as IResource, DateTime.UtcNow);
var rid = resource.Instance.Id; var rid = resource.Instance.Id;
@@ -888,7 +887,7 @@ public static class DataSerializer
} }
} }
public static unsafe TDU MapComposer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU MapComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 1); return new TDU(TDUIdentifier.Null, new byte[0], 1);
@@ -902,21 +901,21 @@ public static class DataSerializer
return new TDU(TDUIdentifier.Map, rt.ToArray(), (uint)rt.Count); return new TDU(TDUIdentifier.Map, rt.ToArray(), (uint)rt.Count);
} }
public static unsafe TDU UUIDComposer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU UUIDComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
return new TDU(TDUIdentifier.UUID, ((UUID)value).Data, 16); return new TDU(TDUIdentifier.UUID, ((UUID)value).Data, 16);
} }
public static unsafe TDU RecordComposer(object value, Warehouse warehouse, DistributedConnection connection) public static unsafe TDU RecordComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
var rt = new List<byte>(); var rt = new List<byte>();
var record = (IRecord)value; var record = (IRecord)value;
var template = warehouse.GetTemplateByType(record.GetType()); var typeDef = warehouse.GetTypeDefByType(record.GetType());
foreach (var pt in template.Properties) foreach (var pt in typeDef.Properties)
{ {
var propValue = pt.PropertyInfo.GetValue(record, null); var propValue = pt.PropertyInfo.GetValue(record, null);
@@ -940,11 +939,11 @@ public static class DataSerializer
return new TDU(TDUIdentifier.Record, rt.ToArray(), return new TDU(TDUIdentifier.Record, rt.ToArray(),
(uint)rt.Count, (uint)rt.Count,
template.ClassId.Data); typeDef.Id.Data);
} }
public static byte[] HistoryComposer(KeyList<PropertyDefinition, PropertyValue[]> history, Warehouse warehouse, public static byte[] HistoryComposer(KeyList<PropertyDef, PropertyValue[]> history, Warehouse warehouse,
DistributedConnection connection, bool prependLength = false) EpConnection connection, bool prependLength = false)
{ {
//@TODO:Test //@TODO:Test
var rt = new BinaryList(); var rt = new BinaryList();
@@ -959,7 +958,7 @@ public static class DataSerializer
return rt.ToArray(); return rt.ToArray();
} }
public static TDU TupleComposer(object value, Warehouse warehouse, DistributedConnection connection) public static TDU TupleComposer(object value, Warehouse warehouse, EpConnection connection)
{ {
if (value == null) if (value == null)
return new TDU(TDUIdentifier.Null, new byte[0], 0); return new TDU(TDUIdentifier.Null, new byte[0], 0);

View File

@@ -25,7 +25,6 @@ SOFTWARE.
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Misc; using Esiur.Misc;
using Esiur.Net.IIP;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -23,7 +23,6 @@ SOFTWARE.
*/ */
using Esiur.Net.IIP;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -52,7 +51,7 @@ class ResourceJsonConverter : JsonConverter<IResource>
writer.WriteStartObject(); writer.WriteStartObject();
foreach (var pt in resource.Instance.Schema.Properties) foreach (var pt in resource.Instance.Definition.Properties)
{ {
var rt = pt.PropertyInfo.GetValue(resource, null); var rt = pt.PropertyInfo.GetValue(resource, null);
if (rt != null && rt.GetType().IsGenericType) if (rt != null && rt.GetType().IsGenericType)

View File

@@ -458,7 +458,7 @@ public static class RuntimeCaster
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsListType(Type t) private static bool IsListType(Type t)
{ {
return t.IsGenericType && t.GetGenericTypeDef() == typeof(List<>); return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@@ -1,5 +1,4 @@
using Esiur.Net.IIP; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;

View File

@@ -1,6 +1,5 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Data.Types; using Esiur.Data.Types;
using Esiur.Net.IIP;
using Esiur.Resource; using Esiur.Resource;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using System; using System;

View File

@@ -107,7 +107,7 @@ public class ConstantDef : MemberDef
var value = ci.GetValue(null); var value = ci.GetValue(null);
if (typeDef?.Type == TypeDefKind.Enum) if (typeDef?.Kind == TypeDefKind.Enum)
value = Convert.ChangeType(value, ci.FieldType.GetEnumUnderlyingType()); value = Convert.ChangeType(value, ci.FieldType.GetEnumUnderlyingType());
Map<string, string> annotations = null; Map<string, string> annotations = null;

View File

@@ -1,6 +1,6 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -217,7 +217,7 @@ public class FunctionDef : MemberDef
if (args.Length > 0) if (args.Length > 0)
{ {
if (args.Last().ParameterType == typeof(DistributedConnection) if (args.Last().ParameterType == typeof(EpConnection)
|| args.Last().ParameterType == typeof(InvocationContext)) || args.Last().ParameterType == typeof(InvocationContext))
args = args.Take(args.Count() - 1).ToArray(); args = args.Take(args.Count() - 1).ToArray();
} }
@@ -286,7 +286,7 @@ public class FunctionDef : MemberDef
{ {
annotations = new Map<string, string>(); annotations = new Map<string, string>();
annotations.Add("", "(" + String.Join(",", annotations.Add("", "(" + String.Join(",",
mi.GetParameters().Where(x => x.ParameterType != typeof(DistributedConnection)) mi.GetParameters().Where(x => x.ParameterType != typeof(EpConnection))
.Select(x => "[" + x.ParameterType.Name + "] " + x.Name)) + ") -> " + mi.ReturnType.Name); .Select(x => "[" + x.ParameterType.Name + "] " + x.Name)) + ") -> " + mi.ReturnType.Name);
} }
@@ -307,7 +307,7 @@ public class FunctionDef : MemberDef
public override string ToString() public override string ToString()
{ {
//return = "(" + String.Join(",", mi.GetParameters().Where(x => x.ParameterType != typeof(DistributedConnection)).Select(x => "[" + x.ParameterType.Name + "] " + x.Name)) + ") -> " + mi.ReturnType.Name; //return = "(" + String.Join(",", mi.GetParameters().Where(x => x.ParameterType != typeof(EpConnection)).Select(x => "[" + x.ParameterType.Name + "] " + x.Name)) + ") -> " + mi.ReturnType.Name;
return $"{ReturnType} {Name}({string.Join(", ", Arguments.Select(a => a.ToString()))})"; return $"{ReturnType} {Name}({string.Join(", ", Arguments.Select(a => a.ToString()))})";
} }

View File

@@ -22,7 +22,7 @@ public class MemberDef
// Inherited = inherited; // Inherited = inherited;
//} //}
public string Fullname => Definition.ClassName + "." + Name; public string Fullname => Definition.Name + "." + Name;
//public virtual byte[] Compose() //public virtual byte[] Compose()
//{ //{

View File

@@ -1,5 +1,5 @@
using Esiur.Data; using Esiur.Data;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -34,7 +34,7 @@ public class PropertyDef : MemberDef
} }
*/ */
//bool ReadOnly; //bool ReadOnly;
//IIPTypes::DataType ReturnType; //EPTypes::DataType ReturnType;
public PropertyPermission Permission public PropertyPermission Permission
{ {
get; get;
@@ -43,7 +43,7 @@ public class PropertyDef : MemberDef
//public bool IsNullable { get; set; } //public bool IsNullable { get; set; }
public bool Recordable public bool HasHistory
{ {
get; get;
set; set;
@@ -87,7 +87,7 @@ public class PropertyDef : MemberDef
var hasAnnotation = ((data[offset] & 0x8) == 0x8); var hasAnnotation = ((data[offset] & 0x8) == 0x8);
var recordable = ((data[offset] & 1) == 1); var hasHistory = ((data[offset] & 1) == 1);
var permission = (PropertyPermission)((data[offset++] >> 1) & 0x3); var permission = (PropertyPermission)((data[offset++] >> 1) & 0x3);
var name = data.GetString(offset + 1, data[offset]); var name = data.GetString(offset + 1, data[offset]);
@@ -116,7 +116,7 @@ public class PropertyDef : MemberDef
Name = name, Name = name,
Inherited = inherited, Inherited = inherited,
Permission = permission, Permission = permission,
Recordable = recordable, HasHistory = hasHistory,
ValueType = valueType, ValueType = valueType,
Annotations = annotations Annotations = annotations
}); });
@@ -127,7 +127,7 @@ public class PropertyDef : MemberDef
{ {
var name = DC.ToBytes(Name); var name = DC.ToBytes(Name);
var pv = ((byte)(Permission) << 1) | (Recordable ? 1 : 0); var pv = ((byte)(Permission) << 1) | (HasHistory ? 1 : 0);
if (Inherited) if (Inherited)
pv |= 0x80; pv |= 0x80;
@@ -193,17 +193,7 @@ public class PropertyDef : MemberDef
} }
} }
//public PropertyTemplate(TypeSchema template, byte index, string name, bool inherited,
// TRU valueType, string readAnnotation = null, string writeAnnotation = null, bool recordable = false)
// : base(template, index, name, inherited)
//{
// this.Recordable = recordable;
// //this.Storage = storage;
// if (readAnnotation != null)
// this.ReadAnnotation = readAnnotation;
// this.WriteAnnotation = writeAnnotation;
// this.ValueType = valueType;
//}
public static PropertyDef MakePropertyDef(Type type, PropertyInfo pi, string name, byte index, PropertyPermission permission, TypeDef schema) public static PropertyDef MakePropertyDef(Type type, PropertyInfo pi, string name, byte index, PropertyPermission permission, TypeDef schema)
{ {
@@ -273,24 +263,12 @@ public class PropertyDef : MemberDef
Inherited = pi.DeclaringType != type, Inherited = pi.DeclaringType != type,
ValueType = propType, ValueType = propType,
PropertyInfo = pi, PropertyInfo = pi,
Recordable = storageAttr == null ? false : storageAttr.Mode == StorageMode.Recordable, HasHistory = storageAttr == null ? false : storageAttr.Mode == StorageMode.History,
Permission = permission, Permission = permission,
Annotations = annotations, Annotations = annotations,
}; };
//var pt = new PropertyTemplate(TypeSchema, index, customName ?? pi.Name, pi.DeclaringType != type, propType);
//if (storageAttr != null)
// pt.Recordable = storageAttr.Mode == StorageMode.Recordable;
//if (annotationAttr != null)
// pt.ReadAnnotation = annotationAttr.Annotation;
//else
// pt.ReadAnnotation = GetTypeAnnotationName(pi.PropertyType);
//pt.PropertyInfo = pi;
//return pt;
} }

View File

@@ -8,9 +8,9 @@ using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using System.Security.Cryptography; using System.Security.Cryptography;
using Esiur.Proxy; using Esiur.Proxy;
using Esiur.Net.IIP;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Protocol;
namespace Esiur.Data.Types; namespace Esiur.Data.Types;
@@ -245,7 +245,7 @@ public class TypeDef
// Get parents // Get parents
while (parentType != null) while (parentType != null)
{ {
var parentTemplate = warehouse.GetTemplateByType(parentType); var parentTemplate = warehouse.GetTypeDefByType(parentType);
if (parentTemplate != null) if (parentTemplate != null)
{ {
list.Add(parentTemplate); list.Add(parentTemplate);
@@ -262,7 +262,7 @@ public class TypeDef
foreach (var functionReturnType in functionReturnTypes) foreach (var functionReturnType in functionReturnTypes)
{ {
var functionReturnTemplate = warehouse.GetTemplateByType(functionReturnType); var functionReturnTemplate = warehouse.GetTypeDefByType(functionReturnType);
if (functionReturnTemplate != null) if (functionReturnTemplate != null)
{ {
if (!bag.Contains(functionReturnTemplate)) if (!bag.Contains(functionReturnTemplate))
@@ -281,7 +281,7 @@ public class TypeDef
foreach (var fpType in fpTypes) foreach (var fpType in fpTypes)
{ {
var fpt = warehouse.GetTemplateByType(fpType); var fpt = warehouse.GetTypeDefByType(fpType);
if (fpt != null) if (fpt != null)
{ {
if (!bag.Contains(fpt)) if (!bag.Contains(fpt))
@@ -293,18 +293,18 @@ public class TypeDef
} }
} }
// skip DistributedConnection argument // skip EpConnection argument
if (args.Length > 0) if (args.Length > 0)
{ {
var last = args.Last(); var last = args.Last();
if (last.ParameterType != typeof(DistributedConnection)) if (last.ParameterType != typeof(EpConnection))
{ {
var fpTypes = GetDistributedTypes(last.ParameterType); var fpTypes = GetDistributedTypes(last.ParameterType);
foreach (var fpType in fpTypes) foreach (var fpType in fpTypes)
{ {
var fpt = warehouse.GetTemplateByType(fpType); var fpt = warehouse.GetTypeDefByType(fpType);
if (fpt != null) if (fpt != null)
{ {
if (!bag.Contains(fpt)) if (!bag.Contains(fpt))
@@ -326,7 +326,7 @@ public class TypeDef
foreach (var propertyType in propertyTypes) foreach (var propertyType in propertyTypes)
{ {
var propertyTemplate = warehouse.GetTemplateByType(propertyType); var propertyTemplate = warehouse.GetTypeDefByType(propertyType);
if (propertyTemplate != null) if (propertyTemplate != null)
{ {
if (!bag.Contains(propertyTemplate)) if (!bag.Contains(propertyTemplate))
@@ -345,7 +345,7 @@ public class TypeDef
foreach (var eventType in eventTypes) foreach (var eventType in eventTypes)
{ {
var eventTemplate = warehouse.GetTemplateByType(eventType); var eventTemplate = warehouse.GetTypeDefByType(eventType);
if (eventTemplate != null) if (eventTemplate != null)
{ {
@@ -398,7 +398,7 @@ public class TypeDef
else else
throw new Exception("Type must implement IResource, IRecord or inherit from DistributedResource."); throw new Exception("Type must implement IResource, IRecord or inherit from DistributedResource.");
IsWrapper = Codec.InheritsClass(type, typeof(DistributedResource)); IsWrapper = Codec.InheritsClass(type, typeof(EpResource));
type = ResourceProxy.GetBaseType(type); type = ResourceProxy.GetBaseType(type);
@@ -410,7 +410,7 @@ public class TypeDef
typeId = GetTypeUUID(type); typeId = GetTypeUUID(type);
if (warehouse != null) if (warehouse != null)
warehouse.RegisterSchema(this); warehouse.RegisterTypeDef(this);
var hierarchy = GetHierarchy(type); var hierarchy = GetHierarchy(type);
@@ -729,6 +729,7 @@ public class TypeDef
byte functionIndex = 0; byte functionIndex = 0;
byte propertyIndex = 0; byte propertyIndex = 0;
byte eventIndex = 0; byte eventIndex = 0;
byte constantIndex = 0;
for (int i = 0; i < methodsCount; i++) for (int i = 0; i < methodsCount; i++)
{ {
@@ -750,14 +751,14 @@ public class TypeDef
} }
else if (type == 2) // Event else if (type == 2) // Event
{ {
var (len, et) = EventDef.Parse(data, offset, propertyIndex++, inherited); var (len, et) = EventDef.Parse(data, offset, eventIndex++, inherited);
offset += len; offset += len;
od.events.Add(et); od.events.Add(et);
} }
// constant // constant
else if (type == 3) else if (type == 3)
{ {
var (len, ct) = ConstantDef.Parse(data, offset, propertyIndex++, inherited); var (len, ct) = ConstantDef.Parse(data, offset, constantIndex++, inherited);
offset += len; offset += len;
od.constants.Add(ct); od.constants.Add(ct);
} }

View File

@@ -1,25 +1,25 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Net.Packets; using Esiur.Net.Packets;
using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Esiur.Net.HTTP; namespace Esiur.Net.HTTP;
public class IIPoHTTP : HTTPFilter public class EPoHTTP : HTTPFilter
{ {
[Attribute] [Attribute]
EntryPoint EntryPoint { get; set; } EntryPoint EntryPoint { get; set; }
public override AsyncReply<bool> Execute(HTTPConnection sender) public override AsyncReply<bool> Execute(HTTPConnection sender)
{ {
if (sender.Request.URL != "iip") if (sender.Request.URL != "EP")
return new AsyncReply<bool>(false); return new AsyncReply<bool>(false);
IIPPacketRequest action = (IIPPacketRequest)Convert.ToByte(sender.Request.Query["a"]); EpPacketRequest action = (EpPacketRequest)Convert.ToByte(sender.Request.Query["a"]);
if (action == IIPPacketRequest.Query) if (action == EpPacketRequest.Query)
{ {
EntryPoint.Query(sender.Request.Query["l"], null).Then(x => EntryPoint.Query(sender.Request.Query["l"], null).Then(x =>
{ {

View File

@@ -28,15 +28,15 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Net.IIP;
using Esiur.Net.Sockets; using Esiur.Net.Sockets;
using Esiur.Core; using Esiur.Core;
using Esiur.Protocol;
namespace Esiur.Net.HTTP; namespace Esiur.Net.HTTP;
public class IIPoWS : HTTPFilter public class EPoWS : HTTPFilter
{ {
[Attribute] [Attribute]
public DistributedServer Server public EpServer Server
{ {
get; get;
set; set;
@@ -59,10 +59,10 @@ public class IIPoWS : HTTPFilter
var wsSocket = new WSocket(tcpSocket); var wsSocket = new WSocket(tcpSocket);
httpServer.Remove(sender); httpServer.Remove(sender);
var iipConnection = new DistributedConnection(); var EPConnection = new EpConnection();
Server.Add(iipConnection); Server.Add(EPConnection);
iipConnection.Assign(wsSocket); EPConnection.Assign(wsSocket);
wsSocket.Begin(); wsSocket.Begin();
return new AsyncReply<bool>(true); return new AsyncReply<bool>(true);

View File

@@ -1,36 +0,0 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Net.Packets;
using Esiur.Security.Membership;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.IIP
{
public class DistributedConnectionConfig
{
public ExceptionLevel ExceptionLevel { get; set; }
= ExceptionLevel.Code | ExceptionLevel.Message | ExceptionLevel.Source | ExceptionLevel.Trace;
public Func<AuthorizationRequest, AsyncReply<object>> Authenticator { get; set; }
public bool AutoReconnect { get; set; } = false;
public uint ReconnectInterval { get; set; } = 5;
public string Username { get; set; }
public bool UseWebSocket { get; set; }
public bool SecureWebSocket { get; set; }
public string Password { get; set; }
public string Token { get; set; }
public ulong TokenIndex { get; set; }
public string Domain { get; set; }
}
}

View File

@@ -1,20 +0,0 @@
using Esiur.Core;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.IIP
{
internal class DistributedResourceAttachRequestInfo
{
public AsyncReply<DistributedResource> Reply { get; set; }
public uint[] RequestSequence { get; set; }
public DistributedResourceAttachRequestInfo(AsyncReply<DistributedResource> reply, uint[] requestSequence)
{
Reply = reply;
RequestSequence = requestSequence;
}
}
}

View File

@@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.IIP;
public interface IPropertyContext
{
object GetValue(DistributedConnection connection);
}
public class PropertyContext<T> : IPropertyContext
{
public T Value { get; private set; }
public DistributedConnection Connection { get; private set; }
public Func<DistributedConnection, T> Method { get; private set; }
public PropertyContext(DistributedConnection connection, T value)
{
this.Value = value;
this.Connection = connection;
}
public PropertyContext(Func<DistributedConnection, T> method)
{
this.Method = method;
}
public static implicit operator PropertyContext<T>(Func<DistributedConnection, T> method)
=> new PropertyContext<T>(method);
public object GetValue(DistributedConnection connection)
{
return Method.Invoke(connection);
}
}

View File

@@ -4,19 +4,19 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public static class IIPAuthExtensions public static class EpAuthExtensions
{ {
public static IIPAuthPacketIAuthFormat GetIAuthFormat(this object value) public static EpAuthPacketIAuthFormat GetIAuthFormat(this object value)
{ {
if (value is string) if (value is string)
return IIPAuthPacketIAuthFormat.Text; return EpAuthPacketIAuthFormat.Text;
else if (value is int || value is uint else if (value is int || value is uint
|| value is byte || value is sbyte || value is byte || value is sbyte
|| value is short || value is ushort || value is short || value is ushort
|| value is long || value is ulong) || value is long || value is ulong)
return IIPAuthPacketIAuthFormat.Number; return EpAuthPacketIAuthFormat.Number;
else if (value.GetType().IsArray) else if (value.GetType().IsArray)
return IIPAuthPacketIAuthFormat.Choice; return EpAuthPacketIAuthFormat.Choice;
throw new Exception("Unknown IAuth format"); throw new Exception("Unknown IAuth format");
} }

View File

@@ -35,33 +35,33 @@ using System.Timers;
namespace Esiur.Net.Packets; namespace Esiur.Net.Packets;
public class IIPAuthPacket : Packet public class EpAuthPacket : Packet
{ {
public IIPAuthPacketCommand Command public EpAuthPacketCommand Command
{ {
get; get;
set; set;
} }
public IIPAuthPacketInitialize Initialization public EpAuthPacketInitialize Initialization
{ {
get; get;
set; set;
} }
public IIPAuthPacketAcknowledge Acknowledgement public EpAuthPacketAcknowledge Acknowledgement
{ {
get; get;
set; set;
} }
public IIPAuthPacketAction Action public EpAuthPacketAction Action
{ {
get; get;
set; set;
} }
public IIPAuthPacketEvent Event public EpAuthPacketEvent Event
{ {
get; get;
set; set;
@@ -92,13 +92,13 @@ public class IIPAuthPacket : Packet
} }
public IIPAuthPacketPublicKeyAlgorithm PublicKeyAlgorithm public EpAuthPacketPublicKeyAlgorithm PublicKeyAlgorithm
{ {
get; get;
set; set;
} }
public IIPAuthPacketHashAlgorithm HashAlgorithm public EpAuthPacketHashAlgorithm HashAlgorithm
{ {
get; get;
set; set;
@@ -176,14 +176,14 @@ public class IIPAuthPacket : Packet
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
Command = (IIPAuthPacketCommand)(data[offset] >> 6); Command = (EpAuthPacketCommand)(data[offset] >> 6);
if (Command == IIPAuthPacketCommand.Initialize) if (Command == EpAuthPacketCommand.Initialize)
{ {
LocalMethod = (AuthenticationMethod)(data[offset] >> 4 & 0x3); LocalMethod = (AuthenticationMethod)(data[offset] >> 4 & 0x3);
RemoteMethod = (AuthenticationMethod)(data[offset] >> 2 & 0x3); RemoteMethod = (AuthenticationMethod)(data[offset] >> 2 & 0x3);
Initialization = (IIPAuthPacketInitialize)(data[offset++] & 0xFC); // remove last two reserved LSBs Initialization = (EpAuthPacketInitialize)(data[offset++] & 0xFC); // remove last two reserved LSBs
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -197,13 +197,13 @@ public class IIPAuthPacket : Packet
offset += (uint)DataType.Value.TotalLength; offset += (uint)DataType.Value.TotalLength;
} }
else if (Command == IIPAuthPacketCommand.Acknowledge) else if (Command == EpAuthPacketCommand.Acknowledge)
{ {
LocalMethod = (AuthenticationMethod)(data[offset] >> 4 & 0x3); LocalMethod = (AuthenticationMethod)(data[offset] >> 4 & 0x3);
RemoteMethod = (AuthenticationMethod)(data[offset] >> 2 & 0x3); RemoteMethod = (AuthenticationMethod)(data[offset] >> 2 & 0x3);
Acknowledgement = (IIPAuthPacketAcknowledge)(data[offset++] & 0xFC); // remove last two reserved LSBs Acknowledgement = (EpAuthPacketAcknowledge)(data[offset++] & 0xFC); // remove last two reserved LSBs
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -216,19 +216,19 @@ public class IIPAuthPacket : Packet
offset += (uint)DataType.Value.TotalLength; offset += (uint)DataType.Value.TotalLength;
} }
else if (Command == IIPAuthPacketCommand.Action) else if (Command == EpAuthPacketCommand.Action)
{ {
Action = (IIPAuthPacketAction)data[offset++]; // (IIPAuthPacketAction)(data[offset++] & 0x3f); Action = (EpAuthPacketAction)data[offset++]; // (EPAuthPacketAction)(data[offset++] & 0x3f);
if (Action == IIPAuthPacketAction.AuthenticateHash if (Action == EpAuthPacketAction.AuthenticateHash
|| Action == IIPAuthPacketAction.AuthenticatePublicHash || Action == EpAuthPacketAction.AuthenticatePublicHash
|| Action == IIPAuthPacketAction.AuthenticatePrivateHash || Action == EpAuthPacketAction.AuthenticatePrivateHash
|| Action == IIPAuthPacketAction.AuthenticatePublicPrivateHash) || Action == EpAuthPacketAction.AuthenticatePublicPrivateHash)
{ {
if (NotEnough(offset, ends, 3)) if (NotEnough(offset, ends, 3))
return -dataLengthNeeded; return -dataLengthNeeded;
HashAlgorithm = (IIPAuthPacketHashAlgorithm)data[offset++]; HashAlgorithm = (EpAuthPacketHashAlgorithm)data[offset++];
var hashLength = data.GetUInt16(offset, Endian.Little); var hashLength = data.GetUInt16(offset, Endian.Little);
offset += 2; offset += 2;
@@ -241,13 +241,13 @@ public class IIPAuthPacket : Packet
offset += hashLength; offset += hashLength;
} }
else if (Action == IIPAuthPacketAction.AuthenticatePrivateHashCert else if (Action == EpAuthPacketAction.AuthenticatePrivateHashCert
|| Action == IIPAuthPacketAction.AuthenticatePublicPrivateHashCert) || Action == EpAuthPacketAction.AuthenticatePublicPrivateHashCert)
{ {
if (NotEnough(offset, ends, 3)) if (NotEnough(offset, ends, 3))
return -dataLengthNeeded; return -dataLengthNeeded;
HashAlgorithm = (IIPAuthPacketHashAlgorithm)data[offset++]; HashAlgorithm = (EpAuthPacketHashAlgorithm)data[offset++];
var hashLength = data.GetUInt16(offset, Endian.Little); var hashLength = data.GetUInt16(offset, Endian.Little);
offset += 2; offset += 2;
@@ -272,7 +272,7 @@ public class IIPAuthPacket : Packet
offset += certLength; offset += certLength;
} }
else if (Action == IIPAuthPacketAction.IAuthPlain) else if (Action == EpAuthPacketAction.IAuthPlain)
{ {
if (NotEnough(offset, ends, 5)) if (NotEnough(offset, ends, 5))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -288,7 +288,7 @@ public class IIPAuthPacket : Packet
offset += (uint)DataType.Value.TotalLength; offset += (uint)DataType.Value.TotalLength;
} }
else if (Action == IIPAuthPacketAction.IAuthHashed) else if (Action == EpAuthPacketAction.IAuthHashed)
{ {
if (NotEnough(offset, ends, 7)) if (NotEnough(offset, ends, 7))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -296,7 +296,7 @@ public class IIPAuthPacket : Packet
Reference = data.GetUInt32(offset, Endian.Little); Reference = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
HashAlgorithm = (IIPAuthPacketHashAlgorithm)data[offset++]; HashAlgorithm = (EpAuthPacketHashAlgorithm)data[offset++];
var cl = data.GetUInt16(offset, Endian.Little); var cl = data.GetUInt16(offset, Endian.Little);
offset += 2; offset += 2;
@@ -309,7 +309,7 @@ public class IIPAuthPacket : Packet
offset += cl; offset += cl;
} }
else if (Action == IIPAuthPacketAction.IAuthEncrypted) else if (Action == EpAuthPacketAction.IAuthEncrypted)
{ {
if (NotEnough(offset, ends, 7)) if (NotEnough(offset, ends, 7))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -317,7 +317,7 @@ public class IIPAuthPacket : Packet
Reference = data.GetUInt32(offset, Endian.Little); Reference = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
PublicKeyAlgorithm = (IIPAuthPacketPublicKeyAlgorithm)data[offset++]; PublicKeyAlgorithm = (EpAuthPacketPublicKeyAlgorithm)data[offset++];
var cl = data.GetUInt16(offset, Endian.Little); var cl = data.GetUInt16(offset, Endian.Little);
offset += 2; offset += 2;
@@ -330,11 +330,11 @@ public class IIPAuthPacket : Packet
offset += cl; offset += cl;
} }
else if (Action == IIPAuthPacketAction.EstablishNewSession) else if (Action == EpAuthPacketAction.EstablishNewSession)
{ {
// Nothing here // Nothing here
} }
else if (Action == IIPAuthPacketAction.EstablishResumeSession) else if (Action == EpAuthPacketAction.EstablishResumeSession)
{ {
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -349,7 +349,7 @@ public class IIPAuthPacket : Packet
offset += sessionLength; offset += sessionLength;
} }
else if (Action == IIPAuthPacketAction.EncryptKeyExchange) else if (Action == EpAuthPacketAction.EncryptKeyExchange)
{ {
if (NotEnough(offset, ends, 2)) if (NotEnough(offset, ends, 2))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -366,13 +366,13 @@ public class IIPAuthPacket : Packet
offset += keyLength; offset += keyLength;
} }
else if (Action == IIPAuthPacketAction.RegisterEndToEndKey else if (Action == EpAuthPacketAction.RegisterEndToEndKey
|| Action == IIPAuthPacketAction.RegisterHomomorphic) || Action == EpAuthPacketAction.RegisterHomomorphic)
{ {
if (NotEnough(offset, ends, 3)) if (NotEnough(offset, ends, 3))
return -dataLengthNeeded; return -dataLengthNeeded;
PublicKeyAlgorithm = (IIPAuthPacketPublicKeyAlgorithm)data[offset++]; PublicKeyAlgorithm = (EpAuthPacketPublicKeyAlgorithm)data[offset++];
var keyLength = data.GetUInt16(offset, Endian.Little); var keyLength = data.GetUInt16(offset, Endian.Little);
@@ -387,14 +387,14 @@ public class IIPAuthPacket : Packet
} }
} }
else if (Command == IIPAuthPacketCommand.Event) else if (Command == EpAuthPacketCommand.Event)
{ {
Event = (IIPAuthPacketEvent)data[offset++]; Event = (EpAuthPacketEvent)data[offset++];
if (Event == IIPAuthPacketEvent.ErrorTerminate if (Event == EpAuthPacketEvent.ErrorTerminate
|| Event == IIPAuthPacketEvent.ErrorMustEncrypt || Event == EpAuthPacketEvent.ErrorMustEncrypt
|| Event == IIPAuthPacketEvent.ErrorRetry) || Event == EpAuthPacketEvent.ErrorRetry)
{ {
if (NotEnough(offset, ends, 3)) if (NotEnough(offset, ends, 3))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -411,7 +411,7 @@ public class IIPAuthPacket : Packet
offset += msgLength; offset += msgLength;
} }
else if (Event == IIPAuthPacketEvent.IndicationEstablished) else if (Event == EpAuthPacketEvent.IndicationEstablished)
{ {
if (NotEnough(offset, ends, 2)) if (NotEnough(offset, ends, 2))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -438,9 +438,9 @@ public class IIPAuthPacket : Packet
offset += accountLength; offset += accountLength;
} }
else if (Event == IIPAuthPacketEvent.IAuthPlain else if (Event == EpAuthPacketEvent.IAuthPlain
|| Event == IIPAuthPacketEvent.IAuthHashed || Event == EpAuthPacketEvent.IAuthHashed
|| Event == IIPAuthPacketEvent.IAuthEncrypted) || Event == EpAuthPacketEvent.IAuthEncrypted)
{ {
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketAcknowledge : byte public enum EpAuthPacketAcknowledge : byte
{ {
NoAuthNoAuth = 0x40, // 0b01000000, NoAuthNoAuth = 0x40, // 0b01000000,
NoAuthCredentials = 0x44, // 0b01000100, NoAuthCredentials = 0x44, // 0b01000100,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketAction : byte public enum EpAuthPacketAction : byte
{ {
AuthenticateHash = 0x80, AuthenticateHash = 0x80,
AuthenticatePublicHash = 0x81, AuthenticatePublicHash = 0x81,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketCommand : byte public enum EpAuthPacketCommand : byte
{ {
Initialize = 0x0, Initialize = 0x0,
Acknowledge = 0x1, Acknowledge = 0x1,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketEvent : byte public enum EpAuthPacketEvent : byte
{ {
ErrorTerminate = 0xC0, ErrorTerminate = 0xC0,
ErrorMustEncrypt = 0xC1, ErrorMustEncrypt = 0xC1,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketHashAlgorithm public enum EpAuthPacketHashAlgorithm
{ {
SHA256, SHA256,
SHA3, SHA3,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketHeader public enum EpAuthPacketHeader
{ {
Version = 0, Version = 0,
Domain = 1, Domain = 1,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketIAuthDestination public enum EpAuthPacketIAuthDestination
{ {
Self = 0, Self = 0,
Device = 1, // logged in device Device = 1, // logged in device

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketIAuthFormat public enum EpAuthPacketIAuthFormat
{ {
None = 0, None = 0,
Number = 1, Number = 1,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketIAuthHeader : byte public enum EpAuthPacketIAuthHeader : byte
{ {
Reference = 0, Reference = 0,
Destination = 1, Destination = 1,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketInitialize public enum EpAuthPacketInitialize
{ {
NoAuthNoAuth = 0x0, //0b00000000, NoAuthNoAuth = 0x0, //0b00000000,
NoAuthCredentials = 0x4, //0b00000100, NoAuthCredentials = 0x4, //0b00000100,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPAuthPacketPublicKeyAlgorithm public enum EpAuthPacketPublicKeyAlgorithm
{ {
RSA = 0, RSA = 0,
CKKS = 1, CKKS = 1,

View File

@@ -32,15 +32,15 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Esiur.Net.Packets; namespace Esiur.Net.Packets;
class IIPPacket : Packet class EpPacket : Packet
{ {
public uint CallbackId { get; set; } public uint CallbackId { get; set; }
public IIPPacketMethod Method { get; set; } public EpPacketMethod Method { get; set; }
public IIPPacketRequest Request { get; set; } public EpPacketRequest Request { get; set; }
public IIPPacketReply Reply { get; set; } public EpPacketReply Reply { get; set; }
public IIPPacketNotification Notification { get; set; } public EpPacketNotification Notification { get; set; }
public byte Extension { get; set; } public byte Extension { get; set; }
@@ -59,10 +59,10 @@ class IIPPacket : Packet
{ {
return Method switch return Method switch
{ {
IIPPacketMethod.Notification => $"{Method} {Notification}", EpPacketMethod.Notification => $"{Method} {Notification}",
IIPPacketMethod.Request => $"{Method} {Request}", EpPacketMethod.Request => $"{Method} {Request}",
IIPPacketMethod.Reply => $"{Method} {Reply}", EpPacketMethod.Reply => $"{Method} {Reply}",
IIPPacketMethod.Extension => $"{Method} {Extension}", EpPacketMethod.Extension => $"{Method} {Extension}",
_ => $"{Method}" _ => $"{Method}"
}; };
} }
@@ -88,15 +88,15 @@ class IIPPacket : Packet
var hasDTU = (data[offset] & 0x20) == 0x20; var hasDTU = (data[offset] & 0x20) == 0x20;
Method = (IIPPacketMethod)(data[offset] >> 6); Method = (EpPacketMethod)(data[offset] >> 6);
if (Method == IIPPacketMethod.Notification) if (Method == EpPacketMethod.Notification)
{ {
Notification = (IIPPacketNotification)(data[offset++] & 0x1f); Notification = (EpPacketNotification)(data[offset++] & 0x1f);
} }
else if (Method == IIPPacketMethod.Request) else if (Method == EpPacketMethod.Request)
{ {
Request = (IIPPacketRequest)(data[offset++] & 0x1f); Request = (EpPacketRequest)(data[offset++] & 0x1f);
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -104,9 +104,9 @@ class IIPPacket : Packet
CallbackId = data.GetUInt32(offset, Endian.Little); CallbackId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Method == IIPPacketMethod.Reply) else if (Method == EpPacketMethod.Reply)
{ {
Reply = (IIPPacketReply)(data[offset++] & 0x1f); Reply = (EpPacketReply)(data[offset++] & 0x1f);
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -114,7 +114,7 @@ class IIPPacket : Packet
CallbackId = data.GetUInt32(offset, Endian.Little); CallbackId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Method == IIPPacketMethod.Extension) else if (Method == EpPacketMethod.Extension)
{ {
Extension = (byte)(data[offset++] & 0x1f); Extension = (byte)(data[offset++] & 0x1f);
} }

View File

@@ -5,14 +5,14 @@ using System.Text;
namespace Esiur.Net.Packets; namespace Esiur.Net.Packets;
struct IIPPacketAttachInfo struct EpPacketAttachInfo
{ {
public string Link; public string Link;
public ulong Age; public ulong Age;
public byte[] Content; public byte[] Content;
public UUID TypeId; public UUID TypeId;
public IIPPacketAttachInfo(UUID typeId, ulong age, string link, byte[] content) public EpPacketAttachInfo(UUID typeId, ulong age, string link, byte[] content)
{ {
TypeId = typeId; TypeId = typeId;
Age = age; Age = age;

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketMethod : byte public enum EpPacketMethod : byte
{ {
Notification = 0, Notification = 0,
Request, Request,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketNotification : byte public enum EpPacketNotification : byte
{ {
// Notification Invoke // Notification Invoke
PropertyModified = 0x0, PropertyModified = 0x0,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketReply : byte public enum EpPacketReply : byte
{ {
// Success // Success
Completed = 0x0, Completed = 0x0,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketReport : byte public enum EpPacketReport : byte
{ {
ManagementError, ManagementError,
ExecutionError, ExecutionError,

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketRequest : byte public enum EpPacketRequest : byte
{ {
// Request Invoke // Request Invoke
InvokeFunction = 0x0, InvokeFunction = 0x0,
@@ -13,11 +13,11 @@ namespace Esiur.Net.Packets
Unsubscribe = 0x3, Unsubscribe = 0x3,
// Request Inquire // Request Inquire
SchemaFromClassName = 0x8, TypeDefByName = 0x8,
SchemaFromClassId = 0x9, TypeDefById = 0x9,
SchemaFromResourceId = 0xA, TypeDefByResourceId = 0xA,
Query = 0xB, Query = 0xB,
LinkSchemas = 0xC, LinkTypeDefs = 0xC,
Token = 0xD, Token = 0xD,
GetResourceIdByLink = 0xE, GetResourceIdByLink = 0xE,

View File

@@ -35,7 +35,7 @@ using Esiur.Core;
namespace Esiur.Net.UDP; namespace Esiur.Net.UDP;
/* public class IIPConnection /* public class EPConnection
{ {
public EndPoint SenderPoint; public EndPoint SenderPoint;
public public

View File

@@ -27,13 +27,12 @@ using System.Text;
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
public abstract class EntryPoint : Esiur.Resource.Resource public abstract class EntryPoint : Resource.Resource
{ {
public abstract AsyncReply<IResource> Query(string path, EpConnection sender);
public abstract AsyncReply<IResource> Query(string path, DistributedConnection sender);
protected abstract override bool Create(); protected abstract override bool Create();
} }

View File

@@ -0,0 +1,35 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Net.Packets;
using Esiur.Security.Membership;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Protocol;
public class EpConnectionConfig
{
public ExceptionLevel ExceptionLevel { get; set; }
= ExceptionLevel.Code | ExceptionLevel.Message | ExceptionLevel.Source | ExceptionLevel.Trace;
public Func<AuthorizationRequest, AsyncReply<object>> Authenticator { get; set; }
public bool AutoReconnect { get; set; } = false;
public uint ReconnectInterval { get; set; } = 5;
public string Username { get; set; }
public bool UseWebSocket { get; set; }
public bool SecureWebSocket { get; set; }
public string Password { get; set; }
public string Token { get; set; }
public ulong TokenIndex { get; set; }
public string Domain { get; set; }
}

View File

@@ -2,9 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace Esiur.Net.IIP namespace Esiur.Protocol
{ {
public enum ConnectionStatus public enum EpConnectionStatus
{ {
Closed, Closed,
Connecting, Connecting,

View File

@@ -43,10 +43,10 @@ using Esiur.Resource;
using Esiur.Net.Packets; using Esiur.Net.Packets;
using Esiur.Data.Types; using Esiur.Data.Types;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
//[System.Runtime.InteropServices.ComVisible(true)] //[System.Runtime.InteropServices.ComVisible(true)]
public class DistributedResource : DynamicObject, IResource, INotifyPropertyChanged, IDynamicResource public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDynamicResource
{ {
/// <summary> /// <summary>
@@ -58,7 +58,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
uint instanceId; uint instanceId;
TypeDef typeDef; TypeDef typeDef;
DistributedConnection connection; EpConnection connection;
bool attached = false; bool attached = false;
@@ -71,17 +71,17 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
ulong age; ulong age;
protected object[] properties; protected object[] properties;
internal List<DistributedResource> parents = new List<DistributedResource>(); internal List<EpResource> parents = new List<EpResource>();
internal List<DistributedResource> children = new List<DistributedResource>(); internal List<EpResource> children = new List<EpResource>();
DistributedResourceEvent[] events; EpResourceEvent[] events;
/// <summary> /// <summary>
/// Connection responsible for the distributed resource. /// Connection responsible for the distributed resource.
/// </summary> /// </summary>
public DistributedConnection DistributedResourceConnection public EpConnection DistributedResourceConnection
{ {
get { return connection; } get { return connection; }
} }
@@ -145,7 +145,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
/// <param name="template">Resource template.</param> /// <param name="template">Resource template.</param>
/// <param name="instanceId">Instance Id given by the other end.</param> /// <param name="instanceId">Instance Id given by the other end.</param>
/// <param name="age">Resource age.</param> /// <param name="age">Resource age.</param>
public DistributedResource(DistributedConnection connection, uint instanceId, ulong age, string link) public EpResource(EpConnection connection, uint instanceId, ulong age, string link)
{ {
this.link = link; this.link = link;
this.connection = connection; this.connection = connection;
@@ -163,7 +163,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
this.properties = new object[properties.Length]; this.properties = new object[properties.Length];
this.events = new DistributedResourceEvent[Instance.Definition.Events.Length]; this.events = new EpResourceEvent[Instance.Definition.Events.Length];
for (byte i = 0; i < properties.Length; i++) for (byte i = 0; i < properties.Length; i++)
{ {
@@ -209,7 +209,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
throw new Exception("Function template not found."); throw new Exception("Function template not found.");
if (ft.IsStatic) if (ft.IsStatic)
return connection.StaticCall(Instance.Definition.ClassId, index, args); return connection.StaticCall(Instance.Definition.Id, index, args);
else else
return connection.SendInvoke(instanceId, index, args); return connection.SendInvoke(instanceId, index, args);
} }
@@ -416,7 +416,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
if (et == null) if (et == null)
return false; return false;
events[et.Index] = (DistributedResourceEvent)value; events[et.Index] = (EpResourceEvent)value;
return true; return true;
} }
@@ -448,7 +448,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
/// <summary> /// <summary>
/// Create a new instance of distributed resource. /// Create a new instance of distributed resource.
/// </summary> /// </summary>
public DistributedResource() public EpResource()
{ {
//stack = new DistributedResourceStack(this); //stack = new DistributedResourceStack(this);
//this.Instance.ResourceModified += this.OnModified; //this.Instance.ResourceModified += this.OnModified;
@@ -553,7 +553,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
return; return;
} }
~DistributedResource() ~EpResource()
{ {
Destroy(); Destroy();
} }

View File

@@ -0,0 +1,19 @@
using Esiur.Core;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Protocol;
internal class EpResourceAttachRequestInfo
{
public AsyncReply<EpResource> Reply { get; set; }
public uint[] RequestSequence { get; set; }
public EpResourceAttachRequestInfo(AsyncReply<EpResource> reply, uint[] requestSequence)
{
Reply = reply;
RequestSequence = requestSequence;
}
}

View File

@@ -28,6 +28,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
public delegate void DistributedResourceEvent(DistributedResource sender, object argument); public delegate void EpResourceEvent(EpResource sender, object argument);

View File

@@ -28,8 +28,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
public class DistributedResourceQueueItem public class EpResourceQueueItem
{ {
public enum DistributedResourceQueueItemType public enum DistributedResourceQueueItemType
{ {
@@ -40,9 +40,9 @@ public class DistributedResourceQueueItem
DistributedResourceQueueItemType type; DistributedResourceQueueItemType type;
byte index; byte index;
object value; object value;
DistributedResource resource; EpResource resource;
public DistributedResourceQueueItem(DistributedResource resource, DistributedResourceQueueItemType type, object value, byte index) public EpResourceQueueItem(EpResource resource, DistributedResourceQueueItemType type, object value, byte index)
{ {
this.resource = resource; this.resource = resource;
this.index = index; this.index = index;
@@ -50,7 +50,7 @@ public class DistributedResourceQueueItem
this.value = value; this.value = value;
} }
public DistributedResource Resource public EpResource Resource
{ {
get { return resource; } get { return resource; }
} }

View File

@@ -35,10 +35,12 @@ using System.Net;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Security.Membership; using Esiur.Security.Membership;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Data.Schema; using Esiur.Data.Types;
using Esiur.Net;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
public class EpServer : NetworkServer<EpConnection>, IResource
{ {
@@ -133,7 +135,7 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
protected override void ClientConnected(DistributedConnection connection) protected override void ClientConnected(EpConnection connection)
{ {
//Task.Delay(10000).ContinueWith((x) => //Task.Delay(10000).ContinueWith((x) =>
//{ //{
@@ -145,20 +147,20 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
} }
public override void Add(DistributedConnection connection) public override void Add(EpConnection connection)
{ {
connection.Server = this; connection.Server = this;
connection.ExceptionLevel = ExceptionLevel; connection.ExceptionLevel = ExceptionLevel;
base.Add(connection); base.Add(connection);
} }
public override void Remove(DistributedConnection connection) public override void Remove(EpConnection connection)
{ {
connection.Server = null; connection.Server = null;
base.Remove(connection); base.Remove(connection);
} }
protected override void ClientDisconnected(DistributedConnection connection) protected override void ClientDisconnected(EpConnection connection)
{ {
//connection.OnReady -= ConnectionReadyEventReceiver; //connection.OnReady -= ConnectionReadyEventReceiver;
//Warehouse.Remove(connection); //Warehouse.Remove(connection);
@@ -168,13 +170,13 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
public struct CallInfo public struct CallInfo
{ {
public FunctionDefinition Template; public FunctionDef Template;
public Delegate Delegate; public Delegate Delegate;
} }
public DistributedServer MapCall(string call, Delegate handler) public EpServer MapCall(string call, Delegate handler)
{ {
var ft = FunctionDefinition.MakeFunctionDef(null, handler.Method, 0, call, null); var ft = FunctionDef.MakeFunctionDef(null, handler.Method, 0, call, null);
Calls.Add(call, new CallInfo() { Delegate = handler, Template = ft }); Calls.Add(call, new CallInfo() { Delegate = handler, Template = ft });
return this; return this;
} }

View File

@@ -25,11 +25,12 @@ SOFTWARE.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Esiur.Net;
using Esiur.Net.Sockets; using Esiur.Net.Sockets;
using Esiur.Security.Authority; using Esiur.Security.Authority;
namespace Esiur.Net.IIP; namespace Esiur.Protocol;
public class DistributedSession : NetworkSession public class EpSession : NetworkSession
{ {
public Source Source { get; set; } public Source Source { get; set; }
public Authentication Authentication { get; set; } public Authentication Authentication { get; set; }

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Protocol;
public interface IPropertyContext
{
object GetValue(EpConnection connection);
}
public class PropertyContext<T> : IPropertyContext
{
public T Value { get; private set; }
public EpConnection Connection { get; private set; }
public Func<EpConnection, T> Method { get; private set; }
public PropertyContext(EpConnection connection, T value)
{
this.Value = value;
this.Connection = connection;
}
public PropertyContext(Func<EpConnection, T> method)
{
this.Method = method;
}
public static implicit operator PropertyContext<T>(Func<EpConnection, T> method)
=> new PropertyContext<T>(method);
public object GetValue(EpConnection connection)
{
return Method.Invoke(connection);
}
}

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Text; using System.Text;
namespace Esiur.Net.IIP namespace Esiur.Protocol
{ {
public class ResourcePropertyChangedEventArgs : PropertyChangedEventArgs public class ResourcePropertyChangedEventArgs : PropertyChangedEventArgs
{ {

View File

@@ -5,7 +5,7 @@
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.Types; using Esiur.Data.Types;
using Esiur.Net.IIP; using Esiur.Protocol;
using Esiur.Resource; using Esiur.Resource;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp;
@@ -52,11 +52,11 @@ namespace Esiur.Proxy
{ {
try try
{ {
if (!TemplateGenerator.urlRegex.IsMatch(path)) if (!TypeDefGenerator.urlRegex.IsMatch(path))
continue; continue;
var parts = TemplateGenerator.urlRegex.Split(path); var parts = TypeDefGenerator.urlRegex.Split(path);
var con = Warehouse.Default.Get<DistributedConnection>($"{parts[1]}://{parts[2]}").Wait(20000); var con = Warehouse.Default.Get<EpConnection>($"{parts[1]}://{parts[2]}").Wait(20000);
var templates = con.GetLinkDefinitions(parts[3]).Wait(60000); var templates = con.GetLinkDefinitions(parts[3]).Wait(60000);
EmitTemplates(spc, templates); EmitTemplates(spc, templates);
@@ -228,20 +228,20 @@ $@" public partial class {ci.Name} : IResource {{
{ {
if (tmp.Kind == TypeDefKind.Resource) if (tmp.Kind == TypeDefKind.Resource)
{ {
var source = TemplateGenerator.GenerateClass(tmp, templates, false); var source = TypeDefGenerator.GenerateClass(tmp, templates, false);
spc.AddSource(tmp.Name + ".g.cs", source); spc.AddSource(tmp.Name + ".g.cs", source);
} }
else if (tmp.Kind == TypeDefKind.Record) else if (tmp.Kind == TypeDefKind.Record)
{ {
var source = TemplateGenerator.GenerateRecord(tmp, templates); var source = TypeDefGenerator.GenerateRecord(tmp, templates);
spc.AddSource(tmp.Name + ".g.cs", source); spc.AddSource(tmp.Name + ".g.cs", source);
} }
} }
var typesFile = "using System; \r\n namespace Esiur { public static class Generated { public static Type[] Resources {get;} = new Type[] { " + var typesFile = "using System; \r\n namespace Esiur { public static class Generated { public static Type[] Resources {get;} = new Type[] { " +
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.ClassName})")) string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.Name})"))
+ " }; \r\n public static Type[] Records { get; } = new Type[] { " + + " }; \r\n public static Type[] Records { get; } = new Type[] { " +
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.ClassName})")) string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.Name})"))
+ " }; " + + " }; " +
"\r\n } \r\n}"; "\r\n } \r\n}";

View File

@@ -6,13 +6,13 @@ using System.Text;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Net.IIP;
using System.Diagnostics; using System.Diagnostics;
using Esiur.Data.Types; using Esiur.Data.Types;
using Esiur.Protocol;
namespace Esiur.Proxy; namespace Esiur.Proxy;
public static class TemplateGenerator public static class TypeDefGenerator
{ {
internal static Regex urlRegex = new Regex(@"^(?:([\S]*)://([^/]*)/?)"); internal static Regex urlRegex = new Regex(@"^(?:([\S]*)://([^/]*)/?)");
@@ -71,7 +71,7 @@ public static class TemplateGenerator
var rt = new StringBuilder(); var rt = new StringBuilder();
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;"); rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
rt.AppendLine($"namespace {nameSpace} {{"); rt.AppendLine($"namespace {nameSpace} {{");
if (typeDef.Annotations != null) if (typeDef.Annotations != null)
@@ -118,7 +118,7 @@ public static class TemplateGenerator
var rt = new StringBuilder(); var rt = new StringBuilder();
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;"); rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
rt.AppendLine($"namespace {nameSpace} {{"); rt.AppendLine($"namespace {nameSpace} {{");
if (template.Annotations != null) if (template.Annotations != null)
@@ -202,10 +202,10 @@ public static class TemplateGenerator
{ {
if (!urlRegex.IsMatch(url)) if (!urlRegex.IsMatch(url))
throw new Exception("Invalid IIP URL"); throw new Exception("Invalid EP URL");
var path = urlRegex.Split(url); var path = urlRegex.Split(url);
var con = Warehouse.Default.Get<DistributedConnection>(path[1] + "://" + path[2], var con = Warehouse.Default.Get<EpConnection>(path[1] + "://" + path[2],
!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null
).Wait(20000); ).Wait(20000);
@@ -288,7 +288,7 @@ public static class TemplateGenerator
var rt = new StringBuilder(); var rt = new StringBuilder();
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;"); rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
rt.AppendLine("#nullable enable"); rt.AppendLine("#nullable enable");
rt.AppendLine($"namespace {nameSpace} {{"); rt.AppendLine($"namespace {nameSpace} {{");
@@ -306,12 +306,12 @@ public static class TemplateGenerator
// extends // extends
if (template.ParentId == null) if (template.ParentId == null)
rt.AppendLine($"public class {className} : DistributedResource {{"); rt.AppendLine($"public class {className} : EpResource {{");
else else
rt.AppendLine($"public class {className} : {templates.First(x => x.Id == template.ParentId && x.Kind == TypeDefKind.Resource).Name} {{"); rt.AppendLine($"public class {className} : {templates.First(x => x.Id == template.ParentId && x.Kind == TypeDefKind.Resource).Name} {{");
rt.AppendLine($"public {className}(DistributedConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) {{}}"); rt.AppendLine($"public {className}(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) {{}}");
rt.AppendLine($"public {className}() {{}}"); rt.AppendLine($"public {className}() {{}}");
foreach (var f in template.Functions) foreach (var f in template.Functions)
@@ -335,7 +335,7 @@ public static class TemplateGenerator
if (f.IsStatic) if (f.IsStatic)
{ {
rt.Append($"[Export] public static AsyncReply<{rtTypeName}> {f.Name}(DistributedConnection connection"); rt.Append($"[Export] public static AsyncReply<{rtTypeName}> {f.Name}(EpConnection connection");
if (positionalArgs.Length > 0) if (positionalArgs.Length > 0)
rt.Append(", " + rt.Append(", " +

View File

@@ -83,7 +83,7 @@ Now we can add our resource to the memory store using ***Warehouse.Put***
await Warehouse.Put("sys/hello", new HelloResource()); await Warehouse.Put("sys/hello", new HelloResource());
``` ```
To distribute our resource using Esiur IIP Protocol we need to add a DistributedServer To distribute our resource using Esiur EP Protocol we need to add a DistributedServer
```C# ```C#
@@ -111,7 +111,7 @@ To sum up
To access our resource remotely, we need to use it's full path including the protocol, host and instance link. To access our resource remotely, we need to use it's full path including the protocol, host and instance link.
```C# ```C#
dynamic res = await Warehouse.Get<IResource>("iip://localhost/sys/hello"); dynamic res = await Warehouse.Get<IResource>("EP://localhost/sys/hello");
``` ```
Now we can invoke the exported functions and read/write properties; Now we can invoke the exported functions and read/write properties;
@@ -128,7 +128,7 @@ Summing up
>```C# >```C#
> using Esiur.Resource; > using Esiur.Resource;
> >
> dynamic res = await Warehouse.Get<IResource>("iip://localhost/sys/hello"); > dynamic res = await Warehouse.Get<IResource>("EP://localhost/sys/hello");
> >
> var reply = await res.SayHi("Hi, I'm calling you from dotnet"); > var reply = await res.SayHi("Hi, I'm calling you from dotnet");
> >
@@ -146,14 +146,14 @@ Esiur has a self describing feature which comes with every language it supports,
After installing the Esiur nuget package a new command is added to Visual Studio Package Console Manager that is called ***Get-Template***, which generates client side classes for robust static typing. After installing the Esiur nuget package a new command is added to Visual Studio Package Console Manager that is called ***Get-Template***, which generates client side classes for robust static typing.
```ps ```ps
Get-Template iip://localhost/sys/hello Get-Template EP://localhost/sys/hello
``` ```
This will generate and add wrappers for all types needed by our resource. This will generate and add wrappers for all types needed by our resource.
Allowing us to use Allowing us to use
```C# ```C#
var res = await Warehouse.Get<MyResource>("iip://localhost/sys/hello"); var res = await Warehouse.Get<MyResource>("EP://localhost/sys/hello");
var reply = await res.SayHi("Static typing is better"); var reply = await res.SayHi("Static typing is better");
Console.WriteLine(reply); Console.WriteLine(reply);
``` ```

View File

@@ -31,7 +31,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Security.Permissions; using Esiur.Security.Permissions;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Resource; namespace Esiur.Resource;
public interface IStore : IResource public interface IStore : IResource
@@ -39,8 +39,8 @@ public interface IStore : IResource
AsyncReply<IResource> Get(string path); AsyncReply<IResource> Get(string path);
AsyncReply<bool> Put(IResource resource, string path); AsyncReply<bool> Put(IResource resource, string path);
string Link(IResource resource); string Link(IResource resource);
bool Record(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime); //bool Record(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime);
bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime); bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime);
AsyncReply<bool> Remove(IResource resource); AsyncReply<bool> Remove(IResource resource);
AsyncReply<bool> Remove(string path); AsyncReply<bool> Remove(string path);
@@ -73,5 +73,5 @@ public interface IStore : IResource
//AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, ulong fromAge, ulong toAge); //AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, ulong fromAge, ulong toAge);
// AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecordByDate(IResource resource, DateTime fromDate, DateTime toDate); // AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecordByDate(IResource resource, DateTime fromDate, DateTime toDate);
AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate); //AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
} }

View File

@@ -6,7 +6,6 @@ using System.Threading.Tasks;
using Esiur.Data; using Esiur.Data;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Reflection; using System.Reflection;
using Esiur.Net.IIP;
using Esiur.Misc; using Esiur.Misc;
using Esiur.Security.Permissions; using Esiur.Security.Permissions;
using Esiur.Security.Authority; using Esiur.Security.Authority;
@@ -16,6 +15,7 @@ using System.Text.Json;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection.Emit; using System.Reflection.Emit;
using Esiur.Data.Types; using Esiur.Data.Types;
using Esiur.Protocol;
namespace Esiur.Resource; namespace Esiur.Resource;
@@ -482,14 +482,14 @@ public class Instance
ages[pt.Index] = instanceAge; ages[pt.Index] = instanceAge;
modificationDates[pt.Index] = now; modificationDates[pt.Index] = now;
if (pt.Recordable) //if (pt.HasHistory)
{ //{
store.Record(res, pt.Name, value, ages[pt.Index], now); // store.Record(res, pt.Name, value, ages[pt.Index], now);
} //}
else //if (pt.Storage == StorageMode.Recordable) //else //if (pt.Storage == StorageMode.Recordable)
{ //{
store.Modify(res, pt.Name, value, ages[pt.Index], now); store.Modify(res, pt, value, ages[pt.Index], now);
} //}
//ResourceModified?.Invoke(res, pt.Name, value); //ResourceModified?.Invoke(res, pt.Name, value);
@@ -518,7 +518,7 @@ public class Instance
// internal void EmitResourceEvent(string name, string[] users, DistributedConnection[] connections, object[] args) // internal void EmitResourceEvent(string name, string[] users, EpConnection[] connections, object[] args)
internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, EventDef eventDef, object value) internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, EventDef eventDef, object value)
{ {
@@ -678,25 +678,12 @@ public class Instance
} }
/// <summary> /// <summary>
/// Resource template describes the properties, functions and events of the resource. /// Resource TypeDef describes the properties, functions and events of the resource.
/// </summary> /// </summary>
public TypeDef Definition public TypeDef Definition
{ {
get { return definition; } get { return definition; }
/*
internal set
{
template = Warehouse.GetTemplate(resource.GetType());
// set ages
for (byte i = 0; i < template.Properties.Length; i++)
{
ages.Add(0);
modificationDates.Add(DateTime.MinValue);
}
}
*/
} }
/// <summary> /// <summary>
@@ -766,7 +753,7 @@ public class Instance
} }
else else
{ {
this.definition = Warehouse.GetTemplateByType(resource.GetType()); this.definition = Warehouse.GetTypeDefByType(resource.GetType());
} }
// set ages // set ages
@@ -778,7 +765,7 @@ public class Instance
// connect events // connect events
if (!(resource is DistributedResource)) if (!(resource is EpResource))
{ {
Type t = ResourceProxy.GetBaseType(resource); Type t = ResourceProxy.GetBaseType(resource);

View File

@@ -23,7 +23,6 @@ SOFTWARE.
*/ */
using Esiur.Data; using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -37,10 +36,10 @@ namespace Esiur.Resource;
public delegate void ResourceEventHandler<in T>(T argument);//where T : class; public delegate void ResourceEventHandler<in T>(T argument);//where T : class;
// public delegate void CustomUsersEventHanlder(string[] usernames, params object[] args); // public delegate void CustomUsersEventHanlder(string[] usernames, params object[] args);
//public delegate void CustomReceiversEventHanlder(DistributedConnection[] connections, params object[] args); //public delegate void CustomReceiversEventHanlder(EpConnection[] connections, params object[] args);
//public delegate void CustomInquirerEventHanlder(object inquirer, params object[] args); //public delegate void CustomInquirerEventHanlder(object inquirer, params object[] args);
public delegate void CustomResourceEventHandler<in T>(object issuer, Func<Session, bool> receivers, T argument);// object issuer, Session[] receivers, params object[] args); public delegate void CustomResourceEventHandler<in T>(object issuer, Func<Session, bool> receivers, T argument);// object issuer, Session[] receivers, params object[] args);
// public delegate void CustomReceiversEventHanlder(string[] usernames, DistributedConnection[] connections, params object[] args); // public delegate void CustomReceiversEventHanlder(string[] usernames, EpConnection[] connections, params object[] args);

View File

@@ -7,5 +7,5 @@ public enum StorageMode : byte
{ {
NonVolatile, NonVolatile,
Volatile, Volatile,
Recordable History
} }

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Resource; namespace Esiur.Resource;
public abstract class Store<T> : IStore where T : IResource public abstract class Store<T> : IStore where T : IResource
@@ -23,12 +23,12 @@ public abstract class Store<T> : IStore where T : IResource
public abstract AsyncReply<IResource> Get(string path); public abstract AsyncReply<IResource> Get(string path);
public abstract AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate); public abstract AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
public abstract string Link(IResource resource); public abstract string Link(IResource resource);
public abstract bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime); public abstract bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime);
public abstract AsyncReply<bool> Put(IResource resource, string path); public abstract AsyncReply<bool> Put(IResource resource, string path);

View File

@@ -26,8 +26,8 @@ using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.Types; using Esiur.Data.Types;
using Esiur.Misc; using Esiur.Misc;
using Esiur.Net.IIP;
using Esiur.Net.Packets; using Esiur.Net.Packets;
using Esiur.Protocol;
using Esiur.Proxy; using Esiur.Proxy;
using Esiur.Security.Permissions; using Esiur.Security.Permissions;
using System; using System;
@@ -59,13 +59,11 @@ public class Warehouse
uint resourceCounter = 0; uint resourceCounter = 0;
KeyList<TypeDefKind, KeyList<UUID, TypeDef>> schemas KeyList<TypeDefKind, KeyList<UUID, TypeDef>> typeDefs
= new KeyList<TypeDefKind, KeyList<UUID, TypeDef>>() = new KeyList<TypeDefKind, KeyList<UUID, TypeDef>>()
{ {
//[TemplateType.Unspecified] = new KeyList<Guid, TypeSchema>(),
[TypeDefKind.Resource] = new KeyList<UUID, TypeDef>(), [TypeDefKind.Resource] = new KeyList<UUID, TypeDef>(),
[TypeDefKind.Record] = new KeyList<UUID, TypeDef>(), [TypeDefKind.Record] = new KeyList<UUID, TypeDef>(),
//[TemplateType.Wrapper] = new KeyList<Guid, TypeSchema>(),
[TypeDefKind.Enum] = new KeyList<UUID, TypeDef>(), [TypeDefKind.Enum] = new KeyList<UUID, TypeDef>(),
}; };
@@ -84,14 +82,14 @@ public class Warehouse
public Warehouse() public Warehouse()
{ {
Protocols.Add("iip", Protocols.Add("EP",
async (name, attributes) async (name, attributes)
=> await New<DistributedConnection>(name, null, attributes)); => await New<EpConnection>(name, null, attributes));
new TypeDef(typeof(IIPAuthPacketIAuthHeader), this); new TypeDef(typeof(EpAuthPacketIAuthHeader), this);
new TypeDef(typeof(IIPAuthPacketIAuthDestination), this); new TypeDef(typeof(EpAuthPacketIAuthDestination), this);
new TypeDef(typeof(IIPAuthPacketIAuthFormat), this); new TypeDef(typeof(EpAuthPacketIAuthFormat), this);
} }
@@ -139,19 +137,19 @@ public class Warehouse
var resourceTypes = (Type[])generatedType.GetProperty("Resources").GetValue(null); var resourceTypes = (Type[])generatedType.GetProperty("Resources").GetValue(null);
foreach (var t in resourceTypes) foreach (var t in resourceTypes)
{ {
RegisterSchema(new TypeDef(t)); RegisterTypeDef(new TypeDef(t));
} }
var recordTypes = (Type[])generatedType.GetProperty("Records").GetValue(null); var recordTypes = (Type[])generatedType.GetProperty("Records").GetValue(null);
foreach (var t in recordTypes) foreach (var t in recordTypes)
{ {
RegisterSchema(new TypeDef(t)); RegisterTypeDef(new TypeDef(t));
} }
var enumsTypes = (Type[])generatedType.GetProperty("Enums").GetValue(null); var enumsTypes = (Type[])generatedType.GetProperty("Enums").GetValue(null);
foreach (var t in enumsTypes) foreach (var t in enumsTypes)
{ {
RegisterSchema(new TypeDef(t)); RegisterTypeDef(new TypeDef(t));
} }
} }
} }
@@ -339,86 +337,6 @@ public class Warehouse
} }
/// <summary>
/// Put a resource in the warehouse.
/// </summary>
/// <param name="name">Resource name.</param>
/// <param name="resource">Resource instance.</param>
/// <param name="store">IStore that manages the resource. Can be null if the resource is a store.</param>
/// <param name="parent">Parent resource. if not presented the store becomes the parent for the resource.</param>
//public async AsyncReply<T> Put<T>(string instanceName, T resource, IStore store, TypeSchema customTemplate = null, ulong age = 0, IPermissionsManager manager = null, object attributes = null) where T : IResource
//{
// if (resource.Instance != null)
// throw new Exception("Resource has a store.");
// var resourceReference = new WeakReference<IResource>(resource);
// if (resource is IStore && store == null)
// store = (IStore)resource;
// if (store == null)
// throw new Exception("Resource store is not set.");
// resource.Instance = new Instance(this, resourceCounter++, instanceName, resource, store, customTemplate, age);
// if (attributes != null)
// if (attributes is Map<string, object> attrs)
// resource.Instance.SetAttributes(attrs);
// else
// resource.Instance.SetAttributes(Map<string, object>.FromObject(attributes));
// if (manager != null)
// resource.Instance.Managers.Add(manager);
// //if (store == parent)
// // parent = null;
// try
// {
// if (resource is IStore)
// stores.TryAdd(resource as IStore, new List<WeakReference<IResource>>());
// if (!await store.Put(resource))
// throw new Exception("Store failed to put the resource");
// //return default(T);
// //if (parent != null)
// //{
// // await parent.Instance.Store.AddChild(parent, resource);
// // await store.AddParent(resource, parent);
// //}
// var t = resource.GetType();
// Global.Counters["T-" + t.Namespace + "." + t.Name]++;
// resources.TryAdd(resource.Instance.Id, resourceReference);
// if (warehouseIsOpen)
// {
// await resource.Trigger(ResourceTrigger.Initialize);
// if (resource is IStore)
// await resource.Trigger(ResourceTrigger.Open);
// }
// if (resource is IStore)
// StoreConnected?.Invoke(resource as IStore);
// }
// catch (Exception ex)
// {
// Remove(resource);
// throw ex;
// }
// return resource;
//}
/// <summary> /// <summary>
/// Put a resource in the warehouse. /// Put a resource in the warehouse.
/// </summary> /// </summary>
@@ -525,9 +443,9 @@ public class Warehouse
{ {
if (properties is Map<byte, object> map) if (properties is Map<byte, object> map)
{ {
var template = GetTemplateByType(type); var typeDef = GetTypeDefByType(type);
foreach (var kvp in map) foreach (var kvp in map)
template.GetPropertyDefByIndex(kvp.Key).PropertyInfo.SetValue(res, kvp.Value); typeDef.GetPropertyDefByIndex(kvp.Key).PropertyInfo.SetValue(res, kvp.Value);
} }
else else
{ {
@@ -587,22 +505,22 @@ public class Warehouse
/// <summary> /// <summary>
/// Put a resource schema in the schemas warehouse. /// Put a resource schema in the schemas warehouse.
/// </summary> /// </summary>
/// <param name="schema">Resource schema.</param> /// <param name="typeDef">Resource type definition.</param>
public void RegisterSchema(TypeDef typeDef) public void RegisterTypeDef(TypeDef typeDef)
{ {
if (schemas[typeDef.Kind].ContainsKey(typeDef.Id)) if (typeDefs[typeDef.Kind].ContainsKey(typeDef.Id))
throw new Exception($"Template with same class Id already exists. {schemas[typeDef.Kind][typeDef.Id].Name} -> {typeDef.Name}"); throw new Exception($"TypeDef with same class Id already exists. {typeDefs[typeDef.Kind][typeDef.Id].Name} -> {typeDef.Name}");
schemas[typeDef.Kind][typeDef.Id] = typeDef; typeDefs[typeDef.Kind][typeDef.Id] = typeDef;
} }
/// <summary> /// <summary>
/// Get a template by type from the templates warehouse. If not in the warehouse, a new ResourceTemplate is created and added to the warehouse. /// Get a TypeDef by type from the typeDefs warehouse. If not in the warehouse, a new ResourceTemplate is created and added to the warehouse.
/// </summary> /// </summary>
/// <param name="type">.Net type.</param> /// <param name="type">.Net type.</param>
/// <returns>Resource template.</returns> /// <returns>Resource template.</returns>
public TypeDef GetTemplateByType(Type type) public TypeDef GetTypeDefByType(Type type)
{ {
if (!(type.IsClass || type.IsEnum)) if (!(type.IsClass || type.IsEnum))
return null; return null;
@@ -623,7 +541,7 @@ public class Warehouse
else else
return null; return null;
var schema = schemas[schemaKind].Values.FirstOrDefault(x => x.DefinedType == baseType); var schema = typeDefs[schemaKind].Values.FirstOrDefault(x => x.DefinedType == baseType);
if (schema != null) if (schema != null)
return schema; return schema;
@@ -644,27 +562,22 @@ public class Warehouse
if (templateType == null) if (templateType == null)
{ {
// look into resources // look into resources
var template = schemas[TypeDefKind.Resource][typeId]; var template = typeDefs[TypeDefKind.Resource][typeId];
if (template != null) if (template != null)
return template; return template;
// look into records // look into records
template = schemas[TypeDefKind.Record][typeId]; template = typeDefs[TypeDefKind.Record][typeId];
if (template != null) if (template != null)
return template; return template;
// look into enums // look into enums
template = schemas[TypeDefKind.Enum][typeId]; template = typeDefs[TypeDefKind.Enum][typeId];
return template; return template;
//if (template != null)
//// look in wrappers
//template = templates[TemplateType.Wrapper][classId];
//return template;
} }
else else
return schemas[templateType.Value][typeId]; return typeDefs[templateType.Value][typeId];
} }
@@ -673,32 +586,28 @@ public class Warehouse
/// </summary> /// </summary>
/// <param name="className">Class name.</param> /// <param name="className">Class name.</param>
/// <returns>Resource template.</returns> /// <returns>Resource template.</returns>
public TypeDef GetTypeDfByName(string typeName, TypeDefKind? templateType = null) public TypeDef GetTypeDefByName(string typeName, TypeDefKind? typeDefKind = null)
{ {
if (templateType == null) if (typeDefKind == null)
{ {
// look into resources // look into resources
var template = schemas[TypeDefKind.Resource].Values.FirstOrDefault(x => x.Name == typeName); var typeDef = typeDefs[TypeDefKind.Resource].Values.FirstOrDefault(x => x.Name == typeName);
if (template != null) if (typeDef != null)
return template; return typeDef;
// look into records // look into records
template = schemas[TypeDefKind.Record].Values.FirstOrDefault(x => x.Name == typeName); typeDef = typeDefs[TypeDefKind.Record].Values.FirstOrDefault(x => x.Name == typeName);
if (template != null) if (typeDef != null)
return template; return typeDef;
// look into enums // look into enums
template = schemas[TypeDefKind.Enum].Values.FirstOrDefault(x => x.Name == typeName); typeDef = typeDefs[TypeDefKind.Enum].Values.FirstOrDefault(x => x.Name == typeName);
//if (template != null) return typeDef;
return template;
//// look in wrappers
//template = templates[TemplateType.Wrapper].Values.FirstOrDefault(x => x.ClassName == className);
//return template;
} }
else else
{ {
return schemas[templateType.Value].Values.FirstOrDefault(x => x.Name == typeName); return typeDefs[typeDefKind.Value].Values.FirstOrDefault(x => x.Name == typeName);
} }
} }

View File

@@ -27,7 +27,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Esiur.Net.Packets.IIPAuthPacket;
namespace Esiur.Security.Authority; namespace Esiur.Security.Authority;

View File

@@ -48,8 +48,8 @@ public class Session
public ISymetricCipher SymetricCipher { get; set; } = null; public ISymetricCipher SymetricCipher { get; set; } = null;
public Map<IIPAuthPacketHeader, object> LocalHeaders { get; set; } = new Map<IIPAuthPacketHeader, object>(); public Map<EpAuthPacketHeader, object> LocalHeaders { get; set; } = new Map<EpAuthPacketHeader, object>();
public Map<IIPAuthPacketHeader, object> RemoteHeaders { get; set; } = new Map<IIPAuthPacketHeader, object>(); public Map<EpAuthPacketHeader, object> RemoteHeaders { get; set; } = new Map<EpAuthPacketHeader, object>();
public AuthenticationMethod LocalMethod { get; set; } public AuthenticationMethod LocalMethod { get; set; }
public AuthenticationMethod RemoteMethod { get; set; } public AuthenticationMethod RemoteMethod { get; set; }

View File

@@ -11,10 +11,10 @@ namespace Esiur.Security.Membership
public class AuthorizationRequest public class AuthorizationRequest
{ {
public uint Reference { get; set; } public uint Reference { get; set; }
public IIPAuthPacketIAuthDestination Destination { get; set; } public EpAuthPacketIAuthDestination Destination { get; set; }
public string Clue { get; set; } public string Clue { get; set; }
public IIPAuthPacketIAuthFormat? RequiredFormat { get; set; } public EpAuthPacketIAuthFormat? RequiredFormat { get; set; }
public IIPAuthPacketIAuthFormat? ContentFormat { get; set; } public EpAuthPacketIAuthFormat? ContentFormat { get; set; }
public object? Content { get; set; } public object? Content { get; set; }
public byte? Trials { get; set; } public byte? Trials { get; set; }
@@ -24,29 +24,29 @@ namespace Esiur.Security.Membership
public int Timeout => Expire.HasValue && Issue.HasValue ? (int)(Expire.Value - Issue.Value).TotalSeconds : 0; public int Timeout => Expire.HasValue && Issue.HasValue ? (int)(Expire.Value - Issue.Value).TotalSeconds : 0;
public AuthorizationRequest(Map<IIPAuthPacketIAuthHeader, object> headers) public AuthorizationRequest(Map<EpAuthPacketIAuthHeader, object> headers)
{ {
Reference = (uint)headers[IIPAuthPacketIAuthHeader.Reference]; Reference = (uint)headers[EpAuthPacketIAuthHeader.Reference];
Destination =(IIPAuthPacketIAuthDestination)headers[IIPAuthPacketIAuthHeader.Destination]; Destination =(EpAuthPacketIAuthDestination)headers[EpAuthPacketIAuthHeader.Destination];
Clue = (string)headers[IIPAuthPacketIAuthHeader.Clue]; Clue = (string)headers[EpAuthPacketIAuthHeader.Clue];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.RequiredFormat)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.RequiredFormat))
RequiredFormat = (IIPAuthPacketIAuthFormat)headers[IIPAuthPacketIAuthHeader.RequiredFormat]; RequiredFormat = (EpAuthPacketIAuthFormat)headers[EpAuthPacketIAuthHeader.RequiredFormat];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.ContentFormat)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.ContentFormat))
ContentFormat = (IIPAuthPacketIAuthFormat)headers[IIPAuthPacketIAuthHeader.ContentFormat]; ContentFormat = (EpAuthPacketIAuthFormat)headers[EpAuthPacketIAuthHeader.ContentFormat];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.Content)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.Content))
Content = headers[IIPAuthPacketIAuthHeader.Content]; Content = headers[EpAuthPacketIAuthHeader.Content];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.Trials)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.Trials))
Trials = (byte)headers[IIPAuthPacketIAuthHeader.Trials]; Trials = (byte)headers[EpAuthPacketIAuthHeader.Trials];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.Issue)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.Issue))
Issue = (DateTime)headers[IIPAuthPacketIAuthHeader.Issue]; Issue = (DateTime)headers[EpAuthPacketIAuthHeader.Issue];
if (headers.ContainsKey(IIPAuthPacketIAuthHeader.Expire)) if (headers.ContainsKey(EpAuthPacketIAuthHeader.Expire))
Expire = (DateTime)headers[IIPAuthPacketIAuthHeader.Expire]; Expire = (DateTime)headers[EpAuthPacketIAuthHeader.Expire];
} }
} }
} }

View File

@@ -13,10 +13,10 @@ namespace Esiur.Security.Membership
public uint Reference { get; set; } public uint Reference { get; set; }
public IIPAuthPacketIAuthDestination Destination { get; set; } public EpAuthPacketIAuthDestination Destination { get; set; }
public string? Clue { get; set; } public string? Clue { get; set; }
public IIPAuthPacketIAuthFormat? RequiredFormat { get; set; } public EpAuthPacketIAuthFormat? RequiredFormat { get; set; }
public IIPAuthPacketIAuthFormat? ContentFormat { get; set; } public EpAuthPacketIAuthFormat? ContentFormat { get; set; }
public object? Content { get; set; } public object? Content { get; set; }
public byte? Trials { get; set; } public byte? Trials { get; set; }

View File

@@ -28,7 +28,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Data; using Esiur.Data;
using Esiur.Net.IIP;
using Esiur.Core; using Esiur.Core;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using Esiur.Resource; using Esiur.Resource;
@@ -47,8 +46,8 @@ public interface IMembership
AsyncReply<byte[]> GetToken(ulong tokenIndex, string domain); AsyncReply<byte[]> GetToken(ulong tokenIndex, string domain);
AsyncReply<AuthorizationResults> Authorize(Session session); AsyncReply<AuthorizationResults> Authorize(Session session);
AsyncReply<AuthorizationResults> AuthorizePlain(Session session, uint reference, object value); AsyncReply<AuthorizationResults> AuthorizePlain(Session session, uint reference, object value);
AsyncReply<AuthorizationResults> AuthorizeHashed(Session session, uint reference, IIPAuthPacketHashAlgorithm algorithm, byte[] value); AsyncReply<AuthorizationResults> AuthorizeHashed(Session session, uint reference, EpAuthPacketHashAlgorithm algorithm, byte[] value);
AsyncReply<AuthorizationResults> AuthorizeEncrypted(Session session, uint reference, IIPAuthPacketPublicKeyAlgorithm algorithm, byte[] value); AsyncReply<AuthorizationResults> AuthorizeEncrypted(Session session, uint reference, EpAuthPacketPublicKeyAlgorithm algorithm, byte[] value);
AsyncReply<bool> Login(Session session); AsyncReply<bool> Login(Session session);
AsyncReply<bool> Logout(Session session); AsyncReply<bool> Logout(Session session);

View File

@@ -79,7 +79,7 @@ namespace Esiur.Security.Membership
var ar = new AuthorizationResults() var ar = new AuthorizationResults()
{ {
Clue = q.Question, Clue = q.Question,
Destination = IIPAuthPacketIAuthDestination.Self, Destination = EpAuthPacketIAuthDestination.Self,
Reference = (uint)r.Next(), Reference = (uint)r.Next(),
RequiredFormat = format, RequiredFormat = format,
Expire = DateTime.Now.AddSeconds(60), Expire = DateTime.Now.AddSeconds(60),
@@ -96,14 +96,14 @@ namespace Esiur.Security.Membership
} }
} }
public AsyncReply<AuthorizationResults> AuthorizeEncrypted(Session session, uint reference, IIPAuthPacketPublicKeyAlgorithm algorithm, byte[] value) public AsyncReply<AuthorizationResults> AuthorizeEncrypted(Session session, uint reference, EpAuthPacketPublicKeyAlgorithm algorithm, byte[] value)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public AsyncReply<AuthorizationResults> AuthorizeHashed(Session session, uint reference, IIPAuthPacketHashAlgorithm algorithm, byte[] value) public AsyncReply<AuthorizationResults> AuthorizeHashed(Session session, uint reference, EpAuthPacketHashAlgorithm algorithm, byte[] value)
{ {
if (algorithm != IIPAuthPacketHashAlgorithm.SHA256) if (algorithm != EpAuthPacketHashAlgorithm.SHA256)
throw new NotImplementedException(); throw new NotImplementedException();
var ar = users[session.AuthorizedAccount].Results.First(x => x.Reference == reference); var ar = users[session.AuthorizedAccount].Results.First(x => x.Reference == reference);
@@ -112,8 +112,8 @@ namespace Esiur.Security.Membership
// compute hash // compute hash
var remoteNonce = (byte[])session.RemoteHeaders[IIPAuthPacketHeader.Nonce]; var remoteNonce = (byte[])session.RemoteHeaders[EpAuthPacketHeader.Nonce];
var localNonce = (byte[])session.LocalHeaders[IIPAuthPacketHeader.Nonce]; var localNonce = (byte[])session.LocalHeaders[EpAuthPacketHeader.Nonce];
var hashFunc = SHA256.Create(); var hashFunc = SHA256.Create();
// local nonce + password or token + remote nonce // local nonce + password or token + remote nonce

View File

@@ -29,7 +29,7 @@ using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Security.Permissions; namespace Esiur.Security.Permissions;
@@ -39,7 +39,7 @@ public class StorePermissionsManager : IPermissionsManager
public Map<string,object> Settings => settings; public Map<string,object> Settings => settings;
public Ruling Applicable(IResource resource, Session session, ActionType action, MemberDefinition member, object inquirer = null) public Ruling Applicable(IResource resource, Session session, ActionType action, MemberDef member, object inquirer = null)
{ {
return resource.Instance.Store.Instance.Applicable(session, action, member, inquirer); return resource.Instance.Store.Instance.Applicable(session, action, member, inquirer);
} }

View File

@@ -29,7 +29,7 @@ using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Security.Authority; using Esiur.Security.Authority;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Security.Permissions; namespace Esiur.Security.Permissions;
@@ -40,7 +40,7 @@ public class UserPermissionsManager : IPermissionsManager
public Map<string,object> Settings => settings; public Map<string,object> Settings => settings;
public Ruling Applicable(IResource resource, Session session, ActionType action, MemberDefinition member, object inquirer) public Ruling Applicable(IResource resource, Session session, ActionType action, MemberDef member, object inquirer)
{ {
Map<string,object> userPermissions = null; Map<string,object> userPermissions = null;

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Stores; namespace Esiur.Stores;
@@ -78,13 +78,13 @@ public class MemoryStore : IStore
throw new NotImplementedException(); throw new NotImplementedException();
} }
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate) public AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime) public bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime)
{ {
return true; return true;
} }

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Esiur.Core; using Esiur.Core;
using Esiur.Data; using Esiur.Data;
using Esiur.Data.Schema; using Esiur.Data.Types;
namespace Esiur.Stores; namespace Esiur.Stores;
public class TemporaryStore : IStore public class TemporaryStore : IStore
@@ -69,13 +69,13 @@ public class TemporaryStore : IStore
throw new NotImplementedException(); throw new NotImplementedException();
} }
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate) public AsyncReply<KeyList<PropertyDef, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public bool Modify(IResource resource, string propertyName, object value, ulong? age, DateTime? dateTime) public bool Modify(IResource resource, PropertyDef propertyDef, object value, ulong? age, DateTime? dateTime)
{ {
return true; return true;
} }

View File

@@ -10,7 +10,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Test namespace Test
{ {
[Resource] [Resource]
[Annotation("A", "B", "C", "D")] [Annotation("A", "B")]
public partial class MyResource public partial class MyResource
{ {
[Export][Annotation("Comment")] string description; [Export][Annotation("Comment")] string description;

View File

@@ -1,11 +1,11 @@
using Esiur.Data; using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using Esiur.Net.IIP;
using Esiur.Resource; using Esiur.Resource;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Esiur.Protocol;
#nullable enable #nullable enable
@@ -183,12 +183,12 @@ public partial class MyService
} }
[Export] [Export]
public void Connection(object a1, int a2, DistributedConnection a3) => public void Connection(object a1, int a2, EpConnection a3) =>
Console.WriteLine($"VoidArgs {a1} {a2} {a3}"); Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
[Export] [Export]
public void ConnectionOptional(object a1, int a2, string a3 = "sss", DistributedConnection? a4 = null) => public void ConnectionOptional(object a1, int a2, string a3 = "sss", EpConnection? a4 = null) =>
Console.WriteLine($"VoidArgs {a1} {a2} {a3}"); Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
[Export] [Export]

View File

@@ -25,7 +25,6 @@ SOFTWARE.
using Esiur.Data; using Esiur.Data;
using Esiur.Core; using Esiur.Core;
using Esiur.Net.HTTP; using Esiur.Net.HTTP;
using Esiur.Net.IIP;
using Esiur.Net.Sockets; using Esiur.Net.Sockets;
using Esiur.Resource; using Esiur.Resource;
using Esiur.Security.Permissions; using Esiur.Security.Permissions;
@@ -49,6 +48,7 @@ using Esiur.Security.Cryptography;
using Esiur.Security.Membership; using Esiur.Security.Membership;
using Esiur.Net.Packets; using Esiur.Net.Packets;
using System.Numerics; using System.Numerics;
using Esiur.Protocol;
namespace Test namespace Test
{ {
@@ -56,7 +56,7 @@ namespace Test
class Program class Program
{ {
static void TestSerialization(object x, DistributedConnection connection = null) static void TestSerialization(object x, EpConnection connection = null)
{ {
var d = Codec.Compose(x, Warehouse.Default, connection); var d = Codec.Compose(x, Warehouse.Default, connection);
@@ -145,7 +145,7 @@ namespace Test
// Create stores to keep objects. // Create stores to keep objects.
var system = await wh.Put("sys", new MemoryStore()); var system = await wh.Put("sys", new MemoryStore());
var server = await wh.Put("sys/server", new DistributedServer() { Membership = membership }); var server = await wh.Put("sys/server", new EpServer() { Membership = membership });
var web = await wh.Put("sys/web", new HTTPServer() { Port = 8088 }); var web = await wh.Put("sys/web", new HTTPServer() { Port = 8088 });
@@ -158,7 +158,7 @@ namespace Test
//TestSerialization(res1); //TestSerialization(res1);
server.MapCall("Hello", (string msg, DateTime time, DistributedConnection sender) => server.MapCall("Hello", (string msg, DateTime time, EpConnection sender) =>
{ {
Console.WriteLine(msg); Console.WriteLine(msg);
return "Hi " + DateTime.UtcNow; return "Hi " + DateTime.UtcNow;
@@ -200,9 +200,9 @@ namespace Test
var format = x.RequiredFormat; var format = x.RequiredFormat;
if (format == IIPAuthPacketIAuthFormat.Number) if (format == EpAuthPacketIAuthFormat.Number)
return new AsyncReply<object>(Convert.ToInt32(10)); return new AsyncReply<object>(Convert.ToInt32(10));
else if (format == IIPAuthPacketIAuthFormat.Text) else if (format == EpAuthPacketIAuthFormat.Text)
return new AsyncReply<object>(Console.ReadLine().Trim()); return new AsyncReply<object>(Console.ReadLine().Trim());
throw new NotImplementedException("Not supported format."); throw new NotImplementedException("Not supported format.");
@@ -211,7 +211,7 @@ namespace Test
private static async void TestClient(IResource local) private static async void TestClient(IResource local)
{ {
var con = await new Warehouse().Get<DistributedConnection>("iip://localhost", new DistributedConnectionConfig var con = await new Warehouse().Get<EpConnection>("EP://localhost", new EpConnectionConfig
{ {
AutoReconnect = true, AutoReconnect = true,
Username = "admin", Username = "admin",
@@ -258,11 +258,11 @@ namespace Test
var t4 = await remote.GetTuple4(1, "A", 1.3, true); var t4 = await remote.GetTuple4(1, "A", 1.3, true);
Console.WriteLine(t4); Console.WriteLine(t4);
remote.StringEvent += new DistributedResourceEvent((sender, args) => remote.StringEvent += new EpResourceEvent((sender, args) =>
Console.WriteLine($"StringEvent {args}") Console.WriteLine($"StringEvent {args}")
); );
remote.ArrayEvent += new DistributedResourceEvent((sender, args) => remote.ArrayEvent += new EpResourceEvent((sender, args) =>
Console.WriteLine($"ArrayEvent {args}") Console.WriteLine($"ArrayEvent {args}")
); );
@@ -270,7 +270,7 @@ namespace Test
//var path = TemplateGenerator.GetTemplate("iip://localhost/sys/service", "Generated"); //var path = TemplateGenerator.GetTemplate("EP://localhost/sys/service", "Generated");
//Console.WriteLine(path); //Console.WriteLine(path);
@@ -295,7 +295,7 @@ namespace Test
static Timer perodicTimer; static Timer perodicTimer;
static void TestObjectProps(IResource local, DistributedResource remote) static void TestObjectProps(IResource local, EpResource remote)
{ {
foreach (var pt in local.Instance.Definition.Properties) foreach (var pt in local.Instance.Definition.Properties)
@@ -333,6 +333,10 @@ namespace Test
return rt; return rt;
} }
else if (value is Record)
{
return value.ToString();
}
else if (value is IRecord) else if (value is IRecord)
{ {
return "{" + String.Join(", ", t.GetProperties().Select(x => x.Name + ": " + x.GetValue(value))) + "}"; return "{" + String.Join(", ", t.GetProperties().Select(x => x.Name + ": " + x.GetValue(value))) + "}";