mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-03-31 10:28:21 +00:00
renaming 2
This commit is contained in:
@@ -25,12 +25,12 @@ SOFTWARE.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Esiur.Core;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Resource;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections;
|
||||
using Esiur.Protocol;
|
||||
|
||||
namespace Esiur.Data;
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace Esiur.Data;
|
||||
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);
|
||||
|
||||
static AsyncParser[][] FixedAsyncParsers = new AsyncParser[][]
|
||||
@@ -189,10 +189,10 @@ public static class Codec
|
||||
/// <param name="data">Bytes array</param>
|
||||
/// <param name="offset">Zero-indexed offset.</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>
|
||||
/// <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);
|
||||
@@ -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)
|
||||
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.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public static bool IsLocalResource(IResource resource, DistributedConnection connection)
|
||||
public static bool IsLocalResource(IResource resource, EpConnection connection)
|
||||
{
|
||||
if (resource == null)
|
||||
throw new NullReferenceException("Resource is null.");
|
||||
|
||||
if (resource is DistributedResource)
|
||||
if (((DistributedResource)(resource)).DistributedResourceConnection == connection)
|
||||
if (resource is EpResource)
|
||||
if (((EpResource)(resource)).DistributedResourceConnection == connection)
|
||||
return true;
|
||||
|
||||
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>()
|
||||
{
|
||||
@@ -382,7 +382,7 @@ public static class Codec
|
||||
|
||||
|
||||
internal static TDU
|
||||
ComposeInternal(object valueOrSource, Warehouse warehouse, DistributedConnection connection)
|
||||
ComposeInternal(object valueOrSource, Warehouse warehouse, EpConnection connection)
|
||||
{
|
||||
if (valueOrSource == null)
|
||||
return new TDU(TDUIdentifier.Null, null, 0);
|
||||
@@ -400,9 +400,9 @@ public static class Codec
|
||||
else if (genericType == typeof(Func<>))
|
||||
{
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -497,10 +497,10 @@ public static class Codec
|
||||
/// Compose a variable
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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);
|
||||
return tdu.Composed;
|
||||
|
||||
@@ -26,8 +26,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Esiur.Net.IIP;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Net.EP;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,115 +14,115 @@ namespace Esiur.Data;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
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])
|
||||
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]);
|
||||
}
|
||||
|
||||
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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>();
|
||||
@@ -229,12 +229,12 @@ public static class DataDeserializer
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -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>();
|
||||
|
||||
@@ -286,7 +286,7 @@ public static class DataDeserializer
|
||||
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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -335,7 +335,7 @@ public static class DataDeserializer
|
||||
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
|
||||
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 rt = new AsyncReply();
|
||||
@@ -443,7 +443,7 @@ public static class DataDeserializer
|
||||
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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -520,7 +520,7 @@ public static class DataDeserializer
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Data.GVWIE;
|
||||
using Esiur.Data.Schema;
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Misc;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using System;
|
||||
@@ -17,7 +17,7 @@ namespace Esiur.Data;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public static class DataDeserializer
|
||||
return null;
|
||||
}
|
||||
|
||||
public static object BooleanTrueParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object BooleanTrueParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public static class DataDeserializer
|
||||
return true;
|
||||
}
|
||||
|
||||
public static object BooleanFalseParserAsync(ParsedTDU tdu, DistributedConnection connection, uint[] requestSequence)
|
||||
public static object BooleanFalseParserAsync(ParsedTDU tdu, EpConnection connection, uint[] requestSequence)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public static class DataDeserializer
|
||||
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;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public static class DataDeserializer
|
||||
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];
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public static class DataDeserializer
|
||||
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];
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
return *(char*)ptr;
|
||||
@@ -87,7 +87,7 @@ public static class DataDeserializer
|
||||
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];
|
||||
}
|
||||
@@ -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])
|
||||
return *(short*)ptr;
|
||||
@@ -110,7 +110,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
return *(ushort*)ptr;
|
||||
@@ -122,7 +122,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
return *(int*)ptr;
|
||||
@@ -134,7 +134,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
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])
|
||||
return *(float*)ptr;
|
||||
@@ -159,7 +159,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
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])
|
||||
return *(decimal*)ptr;
|
||||
@@ -184,7 +184,7 @@ public static class DataDeserializer
|
||||
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);
|
||||
}
|
||||
@@ -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* ptr2 = &tdu.Data[tdu.Offset + 8])
|
||||
@@ -210,7 +210,7 @@ public static class DataDeserializer
|
||||
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* ptr2 = &tdu.Data[tdu.Offset + 8])
|
||||
@@ -224,7 +224,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
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])
|
||||
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])
|
||||
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);
|
||||
if (connection == null)
|
||||
@@ -283,7 +283,7 @@ public static class DataDeserializer
|
||||
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)
|
||||
return new ResourceId(false, tdu.Data[tdu.Offset]);
|
||||
@@ -296,7 +296,7 @@ public static class DataDeserializer
|
||||
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)
|
||||
return new ResourceId(true, tdu.Data[tdu.Offset]);
|
||||
@@ -309,7 +309,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
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])
|
||||
if (connection == null)
|
||||
@@ -340,7 +340,7 @@ public static class DataDeserializer
|
||||
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])
|
||||
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])
|
||||
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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -393,10 +393,10 @@ public static class DataDeserializer
|
||||
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 template = connection.Instance.Warehouse.GetTemplateByClassId(classId,
|
||||
var typeId = tdu.Metadata.GetUUID(0);
|
||||
var typeDef = connection.Instance.Warehouse.GetTypeDefById(typeId,
|
||||
TypeDefKind.Record);
|
||||
var rt = new AsyncReply<IRecord>();
|
||||
|
||||
@@ -410,9 +410,9 @@ public static class DataDeserializer
|
||||
var length = tdu.ContentLength;
|
||||
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);
|
||||
|
||||
@@ -428,7 +428,7 @@ public static class DataDeserializer
|
||||
}
|
||||
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.Identifier = idf;
|
||||
current.Metadata = mt;
|
||||
@@ -454,16 +454,16 @@ public static class DataDeserializer
|
||||
|
||||
list.Then(results =>
|
||||
{
|
||||
if (template.DefinedType != null)
|
||||
if (typeDef.DefinedType != null)
|
||||
{
|
||||
|
||||
var record = Activator.CreateInstance(template.DefinedType) as IRecord;
|
||||
for (var i = 0; i < template.Properties.Length; i++)
|
||||
var record = Activator.CreateInstance(typeDef.DefinedType) as IRecord;
|
||||
for (var i = 0; i < typeDef.Properties.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var v = RuntimeCaster.Cast(results[i], template.Properties[i].PropertyInfo.PropertyType);
|
||||
template.Properties[i].PropertyInfo.SetValue(record, v);
|
||||
var v = RuntimeCaster.Cast(results[i], typeDef.Properties[i].PropertyInfo.PropertyType);
|
||||
typeDef.Properties[i].PropertyInfo.SetValue(record, v);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -477,8 +477,8 @@ public static class DataDeserializer
|
||||
{
|
||||
var record = new Record();
|
||||
|
||||
for (var i = 0; i < template.Properties.Length; i++)
|
||||
record.Add(template.Properties[i].Name, results[i]);
|
||||
for (var i = 0; i < typeDef.Properties.Length; i++)
|
||||
record.Add(typeDef.Properties[i].Name, results[i]);
|
||||
|
||||
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)
|
||||
{
|
||||
// try to get the template from the other end
|
||||
connection.GetTemplate(classId).Then(tmp =>
|
||||
// try to get the TypeDef from the other end
|
||||
connection.GetTypeDefById(typeId).Then(tmp =>
|
||||
{
|
||||
initRecord(tmp);
|
||||
}).Error(x => rt.TriggerError(x));
|
||||
@@ -511,87 +511,20 @@ public static class DataDeserializer
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound,
|
||||
"Template not found for record.");
|
||||
// @TODO: add parse if no TypeDef settings
|
||||
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TypeDefNotFound,
|
||||
"TypeDef not found for record.");
|
||||
}
|
||||
|
||||
var list = new List<object>();
|
||||
@@ -604,7 +537,7 @@ public static class DataDeserializer
|
||||
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);
|
||||
|
||||
@@ -620,7 +553,7 @@ public static class DataDeserializer
|
||||
}
|
||||
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.Identifier = idf;
|
||||
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;
|
||||
for (var i = 0; i < template.Properties.Length; i++)
|
||||
var record = Activator.CreateInstance(typeDef.DefinedType) as IRecord;
|
||||
for (var i = 0; i < typeDef.Properties.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var v = RuntimeCaster.Cast(list[i], template.Properties[i].PropertyInfo.PropertyType);
|
||||
template.Properties[i].PropertyInfo.SetValue(record, v);
|
||||
var v = RuntimeCaster.Cast(list[i], typeDef.Properties[i].PropertyInfo.PropertyType);
|
||||
typeDef.Properties[i].PropertyInfo.SetValue(record, v);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -665,14 +598,14 @@ public static class DataDeserializer
|
||||
{
|
||||
var record = new Record();
|
||||
|
||||
for (var i = 0; i < template.Properties.Length; i++)
|
||||
record.Add(template.Properties[i].Name, list[i]);
|
||||
for (var i = 0; i < typeDef.Properties.Length; i++)
|
||||
record.Add(typeDef.Properties[i].Name, list[i]);
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -682,26 +615,26 @@ public static class DataDeserializer
|
||||
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 template = connection.Instance.Warehouse.GetTemplateByClassId(classId,
|
||||
var typeDef = connection.Instance.Warehouse.GetTypeDefById(typeId,
|
||||
TypeDefKind.Enum);
|
||||
|
||||
if (template != null)
|
||||
if (typeDef != null)
|
||||
{
|
||||
return new AsyncReply(template.Constants[index].Value);
|
||||
return new AsyncReply(typeDef.Constants[index].Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
var reply = new AsyncReply();
|
||||
|
||||
connection.GetTemplate(classId).Then(tmp =>
|
||||
connection.GetTypeDefById(typeId).Then(tmp =>
|
||||
{
|
||||
reply.Trigger(tmp.Constants[index].Value);
|
||||
}).Error(x => reply.TriggerError(x));
|
||||
@@ -713,25 +646,25 @@ public static class DataDeserializer
|
||||
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 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
|
||||
{
|
||||
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound,
|
||||
"Template not found for enum.");
|
||||
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TypeDefNotFound,
|
||||
"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>();
|
||||
|
||||
@@ -784,7 +717,7 @@ public static class DataDeserializer
|
||||
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>();
|
||||
|
||||
@@ -838,7 +771,7 @@ public static class DataDeserializer
|
||||
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>();
|
||||
|
||||
@@ -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();
|
||||
@@ -1105,12 +1038,12 @@ public static class DataDeserializer
|
||||
var enumType = tru.GetRuntimeType(warehouse);
|
||||
|
||||
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++)
|
||||
{
|
||||
var index = tdu.Data[tdu.Offset + i];
|
||||
enums.SetValue(enumTemplate.Constants[index].Value, i);
|
||||
enums.SetValue(enumTypeDef.Constants[index].Value, i);
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -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)
|
||||
{
|
||||
@@ -1419,13 +1352,13 @@ public static class DataDeserializer
|
||||
var enumType = tru.GetRuntimeType(connection.Instance.Warehouse);
|
||||
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
@@ -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
|
||||
var (hdrCs, tru) = TRU.Parse(tdu.Metadata, 0);
|
||||
@@ -1573,7 +1506,7 @@ public static class DataDeserializer
|
||||
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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -1625,13 +1558,13 @@ public static class DataDeserializer
|
||||
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 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[]>();
|
||||
|
||||
@@ -1639,7 +1572,7 @@ public static class DataDeserializer
|
||||
while (offset < ends)
|
||||
{
|
||||
var index = data[offset++];
|
||||
var pt = resource.Instance.Schema.GetPropertyDefByIndex(index);
|
||||
var pt = resource.Instance.Definition.GetPropertyDefByIndex(index);
|
||||
list.Add(pt, null);
|
||||
var cs = data.GetUInt32(offset, Endian.Little);
|
||||
offset += 4;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data.GVWIE;
|
||||
using Esiur.Data.Schema;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System;
|
||||
@@ -17,7 +17,7 @@ public static class DataSerializer
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -211,7 +211,7 @@ public static class DataSerializer
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 rt = new byte[8];
|
||||
@@ -298,7 +298,7 @@ public static class DataSerializer
|
||||
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 rt = new byte[16];
|
||||
@@ -308,7 +308,7 @@ public static class DataSerializer
|
||||
// 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
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);
|
||||
|
||||
@@ -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)
|
||||
return new TDU(TDUIdentifier.Null, null, 0);
|
||||
@@ -406,11 +406,11 @@ public static class DataSerializer
|
||||
//if (warehouse == null)
|
||||
// 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 ct = template.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
|
||||
var ct = typeDef.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
|
||||
|
||||
if (ct == null)
|
||||
return new TDU(TDUIdentifier.Null, null, 0);
|
||||
@@ -418,28 +418,28 @@ public static class DataSerializer
|
||||
//return Codec.ComposeInternal(intVal, warehouse, connection);
|
||||
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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 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)
|
||||
{
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
public static TDU RawDataComposerFromArray(object value, Warehouse warehouse, DistributedConnection connection)
|
||||
public static TDU RawDataComposerFromArray(object value, Warehouse warehouse, EpConnection connection)
|
||||
{
|
||||
var b = (byte[])value;
|
||||
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>;
|
||||
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 array = (object[])value;
|
||||
@@ -491,7 +491,7 @@ public static class DataSerializer
|
||||
// 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);
|
||||
@@ -534,7 +534,7 @@ public static class DataSerializer
|
||||
//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;
|
||||
|
||||
@@ -570,12 +570,12 @@ public static class DataSerializer
|
||||
{
|
||||
|
||||
var rt = new List<byte>();
|
||||
var template = warehouse.GetTemplateByType(tru.GetRuntimeType(warehouse));
|
||||
var typeDef = warehouse.GetTypeDefByType(tru.GetRuntimeType(warehouse));
|
||||
|
||||
foreach (var v in value)
|
||||
{
|
||||
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)
|
||||
throw new Exception("Unknown Enum.");
|
||||
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);
|
||||
|
||||
@@ -644,7 +644,7 @@ public static class DataSerializer
|
||||
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();
|
||||
|
||||
@@ -655,7 +655,7 @@ public static class DataSerializer
|
||||
// .ToArray();
|
||||
//}
|
||||
|
||||
public static TDU PropertyValueArrayComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||
public static TDU PropertyValueArrayComposer(object value, Warehouse warehouse, EpConnection connection)
|
||||
{
|
||||
if (value == null)
|
||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||
@@ -674,7 +674,7 @@ public static class DataSerializer
|
||||
(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)
|
||||
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,
|
||||
// );
|
||||
}
|
||||
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)
|
||||
@@ -775,7 +775,7 @@ public static class DataSerializer
|
||||
// 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)
|
||||
return null;
|
||||
@@ -806,7 +806,7 @@ public static class DataSerializer
|
||||
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)
|
||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||
@@ -817,7 +817,7 @@ public static class DataSerializer
|
||||
(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)
|
||||
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;
|
||||
|
||||
@@ -840,7 +840,7 @@ public static class DataSerializer
|
||||
|
||||
if (Codec.IsLocalResource(resource, connection))
|
||||
{
|
||||
var rid = (resource as DistributedResource).DistributedResourceInstanceId;
|
||||
var rid = (resource as EpResource).DistributedResourceInstanceId;
|
||||
|
||||
if (rid <= 0xFF)
|
||||
return new TDU(TDUIdentifier.LocalResource8, new byte[] { (byte)rid }, 1);
|
||||
@@ -863,7 +863,6 @@ public static class DataSerializer
|
||||
else
|
||||
{
|
||||
|
||||
//rt.Append((value as IResource).Instance.Template.ClassId, (value as IResource).Instance.Id);
|
||||
connection.cache.Add(value as IResource, DateTime.UtcNow);
|
||||
|
||||
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)
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
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 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);
|
||||
|
||||
@@ -940,11 +939,11 @@ public static class DataSerializer
|
||||
|
||||
return new TDU(TDUIdentifier.Record, rt.ToArray(),
|
||||
(uint)rt.Count,
|
||||
template.ClassId.Data);
|
||||
typeDef.Id.Data);
|
||||
}
|
||||
|
||||
public static byte[] HistoryComposer(KeyList<PropertyDefinition, PropertyValue[]> history, Warehouse warehouse,
|
||||
DistributedConnection connection, bool prependLength = false)
|
||||
public static byte[] HistoryComposer(KeyList<PropertyDef, PropertyValue[]> history, Warehouse warehouse,
|
||||
EpConnection connection, bool prependLength = false)
|
||||
{
|
||||
//@TODO:Test
|
||||
var rt = new BinaryList();
|
||||
@@ -959,7 +958,7 @@ public static class DataSerializer
|
||||
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)
|
||||
return new TDU(TDUIdentifier.Null, new byte[0], 0);
|
||||
|
||||
@@ -25,7 +25,6 @@ SOFTWARE.
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Misc;
|
||||
using Esiur.Net.IIP;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -23,7 +23,6 @@ SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -52,7 +51,7 @@ class ResourceJsonConverter : JsonConverter<IResource>
|
||||
|
||||
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);
|
||||
if (rt != null && rt.GetType().IsGenericType)
|
||||
|
||||
@@ -458,7 +458,7 @@ public static class RuntimeCaster
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static bool IsListType(Type t)
|
||||
{
|
||||
return t.IsGenericType && t.GetGenericTypeDef() == typeof(List<>);
|
||||
return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Esiur.Net.IIP;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Resource;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ConstantDef : MemberDef
|
||||
|
||||
var value = ci.GetValue(null);
|
||||
|
||||
if (typeDef?.Type == TypeDefKind.Enum)
|
||||
if (typeDef?.Kind == TypeDefKind.Enum)
|
||||
value = Convert.ChangeType(value, ci.FieldType.GetEnumUnderlyingType());
|
||||
|
||||
Map<string, string> annotations = null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -217,7 +217,7 @@ public class FunctionDef : MemberDef
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (args.Last().ParameterType == typeof(DistributedConnection)
|
||||
if (args.Last().ParameterType == typeof(EpConnection)
|
||||
|| args.Last().ParameterType == typeof(InvocationContext))
|
||||
args = args.Take(args.Count() - 1).ToArray();
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class FunctionDef : MemberDef
|
||||
{
|
||||
annotations = new Map<string, string>();
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -307,7 +307,7 @@ public class FunctionDef : MemberDef
|
||||
|
||||
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()))})";
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MemberDef
|
||||
// Inherited = inherited;
|
||||
//}
|
||||
|
||||
public string Fullname => Definition.ClassName + "." + Name;
|
||||
public string Fullname => Definition.Name + "." + Name;
|
||||
|
||||
//public virtual byte[] Compose()
|
||||
//{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Esiur.Data;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -34,7 +34,7 @@ public class PropertyDef : MemberDef
|
||||
}
|
||||
*/
|
||||
//bool ReadOnly;
|
||||
//IIPTypes::DataType ReturnType;
|
||||
//EPTypes::DataType ReturnType;
|
||||
public PropertyPermission Permission
|
||||
{
|
||||
get;
|
||||
@@ -43,7 +43,7 @@ public class PropertyDef : MemberDef
|
||||
|
||||
//public bool IsNullable { get; set; }
|
||||
|
||||
public bool Recordable
|
||||
public bool HasHistory
|
||||
{
|
||||
get;
|
||||
set;
|
||||
@@ -87,7 +87,7 @@ public class PropertyDef : MemberDef
|
||||
|
||||
|
||||
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 name = data.GetString(offset + 1, data[offset]);
|
||||
|
||||
@@ -116,7 +116,7 @@ public class PropertyDef : MemberDef
|
||||
Name = name,
|
||||
Inherited = inherited,
|
||||
Permission = permission,
|
||||
Recordable = recordable,
|
||||
HasHistory = hasHistory,
|
||||
ValueType = valueType,
|
||||
Annotations = annotations
|
||||
});
|
||||
@@ -127,7 +127,7 @@ public class PropertyDef : MemberDef
|
||||
{
|
||||
var name = DC.ToBytes(Name);
|
||||
|
||||
var pv = ((byte)(Permission) << 1) | (Recordable ? 1 : 0);
|
||||
var pv = ((byte)(Permission) << 1) | (HasHistory ? 1 : 0);
|
||||
|
||||
if (Inherited)
|
||||
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)
|
||||
{
|
||||
@@ -273,24 +263,12 @@ public class PropertyDef : MemberDef
|
||||
Inherited = pi.DeclaringType != type,
|
||||
ValueType = propType,
|
||||
PropertyInfo = pi,
|
||||
Recordable = storageAttr == null ? false : storageAttr.Mode == StorageMode.Recordable,
|
||||
HasHistory = storageAttr == null ? false : storageAttr.Mode == StorageMode.History,
|
||||
Permission = permission,
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ using Esiur.Data;
|
||||
using Esiur.Core;
|
||||
using System.Security.Cryptography;
|
||||
using Esiur.Proxy;
|
||||
using Esiur.Net.IIP;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Esiur.Resource;
|
||||
using Esiur.Protocol;
|
||||
|
||||
namespace Esiur.Data.Types;
|
||||
|
||||
@@ -245,7 +245,7 @@ public class TypeDef
|
||||
// Get parents
|
||||
while (parentType != null)
|
||||
{
|
||||
var parentTemplate = warehouse.GetTemplateByType(parentType);
|
||||
var parentTemplate = warehouse.GetTypeDefByType(parentType);
|
||||
if (parentTemplate != null)
|
||||
{
|
||||
list.Add(parentTemplate);
|
||||
@@ -262,7 +262,7 @@ public class TypeDef
|
||||
|
||||
foreach (var functionReturnType in functionReturnTypes)
|
||||
{
|
||||
var functionReturnTemplate = warehouse.GetTemplateByType(functionReturnType);
|
||||
var functionReturnTemplate = warehouse.GetTypeDefByType(functionReturnType);
|
||||
if (functionReturnTemplate != null)
|
||||
{
|
||||
if (!bag.Contains(functionReturnTemplate))
|
||||
@@ -281,7 +281,7 @@ public class TypeDef
|
||||
|
||||
foreach (var fpType in fpTypes)
|
||||
{
|
||||
var fpt = warehouse.GetTemplateByType(fpType);
|
||||
var fpt = warehouse.GetTypeDefByType(fpType);
|
||||
if (fpt != null)
|
||||
{
|
||||
if (!bag.Contains(fpt))
|
||||
@@ -293,18 +293,18 @@ public class TypeDef
|
||||
}
|
||||
}
|
||||
|
||||
// skip DistributedConnection argument
|
||||
// skip EpConnection argument
|
||||
if (args.Length > 0)
|
||||
{
|
||||
var last = args.Last();
|
||||
if (last.ParameterType != typeof(DistributedConnection))
|
||||
if (last.ParameterType != typeof(EpConnection))
|
||||
{
|
||||
|
||||
var fpTypes = GetDistributedTypes(last.ParameterType);
|
||||
|
||||
foreach (var fpType in fpTypes)
|
||||
{
|
||||
var fpt = warehouse.GetTemplateByType(fpType);
|
||||
var fpt = warehouse.GetTypeDefByType(fpType);
|
||||
if (fpt != null)
|
||||
{
|
||||
if (!bag.Contains(fpt))
|
||||
@@ -326,7 +326,7 @@ public class TypeDef
|
||||
|
||||
foreach (var propertyType in propertyTypes)
|
||||
{
|
||||
var propertyTemplate = warehouse.GetTemplateByType(propertyType);
|
||||
var propertyTemplate = warehouse.GetTypeDefByType(propertyType);
|
||||
if (propertyTemplate != null)
|
||||
{
|
||||
if (!bag.Contains(propertyTemplate))
|
||||
@@ -345,7 +345,7 @@ public class TypeDef
|
||||
|
||||
foreach (var eventType in eventTypes)
|
||||
{
|
||||
var eventTemplate = warehouse.GetTemplateByType(eventType);
|
||||
var eventTemplate = warehouse.GetTypeDefByType(eventType);
|
||||
|
||||
if (eventTemplate != null)
|
||||
{
|
||||
@@ -398,7 +398,7 @@ public class TypeDef
|
||||
else
|
||||
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);
|
||||
|
||||
@@ -410,7 +410,7 @@ public class TypeDef
|
||||
typeId = GetTypeUUID(type);
|
||||
|
||||
if (warehouse != null)
|
||||
warehouse.RegisterSchema(this);
|
||||
warehouse.RegisterTypeDef(this);
|
||||
|
||||
var hierarchy = GetHierarchy(type);
|
||||
|
||||
@@ -729,6 +729,7 @@ public class TypeDef
|
||||
byte functionIndex = 0;
|
||||
byte propertyIndex = 0;
|
||||
byte eventIndex = 0;
|
||||
byte constantIndex = 0;
|
||||
|
||||
for (int i = 0; i < methodsCount; i++)
|
||||
{
|
||||
@@ -750,14 +751,14 @@ public class TypeDef
|
||||
}
|
||||
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;
|
||||
od.events.Add(et);
|
||||
}
|
||||
// constant
|
||||
else if (type == 3)
|
||||
{
|
||||
var (len, ct) = ConstantDef.Parse(data, offset, propertyIndex++, inherited);
|
||||
var (len, ct) = ConstantDef.Parse(data, offset, constantIndex++, inherited);
|
||||
offset += len;
|
||||
od.constants.Add(ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user