2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-03-31 10:28:21 +00:00
This commit is contained in:
2026-03-17 19:10:20 +03:00
parent 3f7e3992c1
commit 8fc07d6350
50 changed files with 443 additions and 434 deletions

View File

@@ -29,7 +29,7 @@ public enum ExceptionCode : ushort
UpdateAttributeFailed,
GetAttributesFailed,
ClearAttributesFailed,
TemplateNotFound,
TypeDefNotFound,
RenameDenied,
ClassNotFound,
MethodNotFound,

View File

@@ -165,7 +165,7 @@ public static class DataDeserializer
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var initRecord = (TypeTemplate template) =>
var initRecord = (TypeSchema template) =>
{
ListParser(data, offset, length, connection, requestSequence).Then(r =>
{

View File

@@ -1,10 +1,10 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Data.GVWIE;
using Esiur.Data.Schema;
using Esiur.Misc;
using Esiur.Net.IIP;
using Esiur.Resource;
using Esiur.Resource.Template;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections;
@@ -397,7 +397,7 @@ public static class DataDeserializer
{
var classId = tdu.Metadata.GetUUID(0);
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId,
TemplateType.Record);
TypeDefKind.Record);
var rt = new AsyncReply<IRecord>();
@@ -410,7 +410,7 @@ public static class DataDeserializer
var length = tdu.ContentLength;
var ends = offset + (uint)length;
var initRecord = (TypeTemplate template) =>
var initRecord = (TypeDef template) =>
{
for (var i = 0; i < template.Properties.Length; i++)
{
@@ -517,7 +517,7 @@ public static class DataDeserializer
//var template = connection.Instance.Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
//var initRecord = (TypeTemplate template) =>
//var initRecord = (TypeSchema template) =>
//{
// ListParserAsync(tdu, connection, requestSequence).Then(r =>
// {
@@ -585,12 +585,12 @@ public static class DataDeserializer
public static unsafe object RecordParser(ParsedTDU tdu, Warehouse warehouse)
{
var classId = tdu.Metadata.GetUUID(0);
var template = warehouse.GetTemplateByClassId(classId, TemplateType.Record);
var template = warehouse.GetTypeDefByClassId(classId, TypeDefKind.Record);
if (template == null)
{
// @TODO: add parse if no template settings
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TemplateNotFound,
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound,
"Template not found for record.");
}
@@ -691,7 +691,7 @@ public static class DataDeserializer
var index = tdu.Data[tdu.Offset];
var template = connection.Instance.Warehouse.GetTemplateByClassId(classId,
TemplateType.Enum);
TypeDefKind.Enum);
if (template != null)
{
@@ -717,7 +717,7 @@ public static class DataDeserializer
var index = tdu.Data[tdu.Offset];
var template = warehouse.GetTemplateByClassId(classId, TemplateType.Enum);
var template = warehouse.GetTemplateByClassId(classId, TypeDefKind.Enum);
if (template != null)
{
@@ -725,7 +725,7 @@ public static class DataDeserializer
}
else
{
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.TemplateNotFound,
throw new AsyncException(ErrorType.Management, (ushort)ExceptionCode.SchemaNotFound,
"Template not found for enum.");
}
}
@@ -1625,13 +1625,13 @@ public static class DataDeserializer
return (16 + valueSize, reply);
}
public static AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> HistoryParserAsync(byte[] data, uint offset, uint length, IResource resource, DistributedConnection connection, uint[] requestSequence)
public static AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> HistoryParserAsync(byte[] data, uint offset, uint length, IResource resource, DistributedConnection connection, uint[] requestSequence)
{
//var count = (int)toAge - (int)fromAge;
var list = new KeyList<PropertyTemplate, PropertyValue[]>();
var list = new KeyList<PropertyDefinition, PropertyValue[]>();
var reply = new AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>>();
var reply = new AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>>();
var bagOfBags = new AsyncBag<PropertyValue[]>();
@@ -1639,7 +1639,7 @@ public static class DataDeserializer
while (offset < ends)
{
var index = data[offset++];
var pt = resource.Instance.Template.GetPropertyTemplateByIndex(index);
var pt = resource.Instance.Schema.GetPropertyDefByIndex(index);
list.Add(pt, null);
var cs = data.GetUInt32(offset, Endian.Little);
offset += 4;

View File

@@ -1,8 +1,8 @@
using Esiur.Core;
using Esiur.Data.GVWIE;
using Esiur.Data.Schema;
using Esiur.Net.IIP;
using Esiur.Resource;
using Esiur.Resource.Template;
using Microsoft.CodeAnalysis;
using System;
using System.Buffers.Binary;
@@ -943,7 +943,7 @@ public static class DataSerializer
template.ClassId.Data);
}
public static byte[] HistoryComposer(KeyList<PropertyTemplate, PropertyValue[]> history, Warehouse warehouse,
public static byte[] HistoryComposer(KeyList<PropertyDefinition, PropertyValue[]> history, Warehouse warehouse,
DistributedConnection connection, bool prependLength = false)
{
//@TODO:Test

View File

@@ -1,5 +1,5 @@
using Esiur.Core;
using Esiur.Resource.Template;
using Esiur.Data.Types;
using System;
using System.Collections.Generic;
using System.Text;
@@ -15,6 +15,6 @@ namespace Esiur.Data
public AsyncReply SetResourcePropertyAsync(byte index, object value);
public void SetResourceProperty(byte index, object value);
public TypeTemplate ResourceTemplate { get; }
public TypeDef ResourceDefinition { get; }
}
}

View File

@@ -466,9 +466,9 @@ namespace Esiur.Data
private static MemberInfo GetMemberMetadataDefinition(MemberInfo member)
{
Type? type = member.DeclaringType;
if ((type != null) && type.IsGenericType && !type.IsGenericTypeDefinition)
if ((type != null) && type.IsGenericType && !type.IsGenericTypeDef)
{
return GetMemberWithSameMetadataDefinitionAs(type.GetGenericTypeDefinition(), member);
return GetMemberWithSameMetadataDefinitionAs(type.GetGenericTypeDef(), member);
}
return member;
@@ -575,20 +575,20 @@ namespace Esiur.Data
{
Debug.Assert(genericParameter.IsGenericParameter && !IsGenericMethodParameter(genericParameter));
Type contextTypeDefinition = context.IsGenericType && !context.IsGenericTypeDefinition ? context.GetGenericTypeDefinition() : context;
if (genericParameter.DeclaringType == contextTypeDefinition)
Type contextTypeDef = context.IsGenericType && !context.IsGenericTypeDef ? context.GetGenericTypeDef() : context;
if (genericParameter.DeclaringType == contextTypeDef)
{
return false;
}
Type? baseType = contextTypeDefinition.BaseType;
Type? baseType = contextTypeDef.BaseType;
if (baseType is null)
{
return false;
}
if (!baseType.IsGenericType
|| (baseType.IsGenericTypeDefinition ? baseType : baseType.GetGenericTypeDefinition()) != genericParameter.DeclaringType)
|| (baseType.IsGenericTypeDef ? baseType : baseType.GetGenericTypeDef()) != genericParameter.DeclaringType)
{
return TryUpdateGenericTypeParameterNullabilityFromReflectedType(nullability, genericParameter, baseType, reflectedType);
}
@@ -600,7 +600,7 @@ namespace Esiur.Data
return TryUpdateGenericParameterNullability(nullability, genericArgument, reflectedType);
}
NullableAttributeStateParser parser = CreateParser(contextTypeDefinition.GetCustomAttributesData());
NullableAttributeStateParser parser = CreateParser(contextTypeDef.GetCustomAttributesData());
int nullabilityStateIndex = 1; // start at 1 since index 0 is the type itself
for (int i = 0; i < genericParameter.GenericParameterPosition; i++)
{

View File

@@ -52,7 +52,7 @@ class ResourceJsonConverter : JsonConverter<IResource>
writer.WriteStartObject();
foreach (var pt in resource.Instance.Template.Properties)
foreach (var pt in resource.Instance.Schema.Properties)
{
var rt = pt.PropertyInfo.GetValue(resource, null);
if (rt != null && rt.GetType().IsGenericType)

View File

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

View File

@@ -1,7 +1,7 @@
using Esiur.Core;
using Esiur.Data.Types;
using Esiur.Net.IIP;
using Esiur.Resource;
using Esiur.Resource.Template;
using Microsoft.CodeAnalysis;
using System;
using System.Collections;
@@ -168,9 +168,9 @@ namespace Esiur.Data
(TRUIdentifier.DateTime) => Nullable ? typeof(DateTime?) : typeof(DateTime),
(TRUIdentifier.Resource) => typeof(IResource),
(TRUIdentifier.Record) => typeof(IRecord),
(TRUIdentifier.TypedRecord) => warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Record)?.DefinedType,
(TRUIdentifier.TypedResource) => warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Resource)?.DefinedType,
(TRUIdentifier.Enum) => warehouse.GetTemplateByClassId((UUID)UUID!, TemplateType.Enum)?.DefinedType,
(TRUIdentifier.TypedRecord) => warehouse.GetTypeDefById((UUID)UUID!, TypeDefKind.Record)?.DefinedType,
(TRUIdentifier.TypedResource) => warehouse.GetTypeDefById((UUID)UUID!, TypeDefKind.Resource)?.DefinedType,
(TRUIdentifier.Enum) => warehouse.GetTypeDefById((UUID)UUID!, TypeDefKind.Enum)?.DefinedType,
_ => null
};
@@ -308,7 +308,7 @@ namespace Esiur.Data
tru = new TRU(
TRUIdentifier.TypedResource,
nullable,
TypeTemplate.GetTypeUUID(type)
TypeDef.GetTypeUUID(type)
);
}
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
@@ -316,7 +316,7 @@ namespace Esiur.Data
tru = new TRU(
TRUIdentifier.TypedRecord,
nullable,
TypeTemplate.GetTypeUUID(type)
TypeDef.GetTypeUUID(type)
);
}
else if (type.IsGenericType)
@@ -483,7 +483,7 @@ namespace Esiur.Data
}
else if (type.IsEnum)
{
tru = new TRU(TRUIdentifier.Enum, nullable, TypeTemplate.GetTypeUUID(type));
tru = new TRU(TRUIdentifier.Enum, nullable, TypeDef.GetTypeUUID(type));
}
else if (type.IsInterface)
{

View File

@@ -4,9 +4,9 @@ using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class ArgumentTemplate
public class ArgumentDef
{
public string Name { get; set; }
@@ -20,7 +20,7 @@ public class ArgumentTemplate
public Map<string, string> Annotations { get; set; }
public static (uint, ArgumentTemplate) Parse(byte[] data, uint offset, int index)
public static (uint, ArgumentDef) Parse(byte[] data, uint offset, int index)
{
var optional = (data[offset] & 0x1) == 0x1;
var hasAnnotations = (data[offset++] & 0x2) == 0x2;
@@ -46,7 +46,7 @@ public class ArgumentTemplate
cs += l;
}
return (cs + 2 + size, new ArgumentTemplate()
return (cs + 2 + size, new ArgumentDef()
{
Name = name,
Index = index,
@@ -56,7 +56,7 @@ public class ArgumentTemplate
});
}
public ArgumentTemplate()
public ArgumentDef()
{
}

View File

@@ -6,9 +6,9 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class AttributeTemplate : MemberTemplate
public class AttributeDef : MemberDef
{
public PropertyInfo PropertyInfo
@@ -18,14 +18,15 @@ public class AttributeTemplate : MemberTemplate
}
public static AttributeTemplate MakeAttributeTemplate(Type type, PropertyInfo pi, byte index, string name, TypeTemplate typeTemplate )
public static AttributeDef MakeAttributeDef(Type type, PropertyInfo pi, byte index, string name, TypeDef typeDef)
{
return new AttributeTemplate()
return new AttributeDef()
{
Index = index,
Inherited = pi.DeclaringType != type,
Name = name,
PropertyInfo = pi
PropertyInfo = pi,
Definition = typeDef
};
}
}

View File

@@ -4,10 +4,11 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using Esiur.Data;
using Esiur.Resource;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class ConstantTemplate : MemberTemplate
public class ConstantDef : MemberDef
{
public object Value { get; set; }
@@ -17,7 +18,7 @@ public class ConstantTemplate : MemberTemplate
public FieldInfo FieldInfo { get; set; }
public static (uint, ConstantTemplate) Parse(byte[] data, uint offset, byte index, bool inherited)
public static (uint, ConstantDef) Parse(byte[] data, uint offset, byte index, bool inherited)
{
var oOffset = offset;
@@ -47,7 +48,7 @@ public class ConstantTemplate : MemberTemplate
offset += len;
}
return (offset - oOffset, new ConstantTemplate()
return (offset - oOffset, new ConstantDef()
{
Index = index,
Name = name,
@@ -95,7 +96,7 @@ public class ConstantTemplate : MemberTemplate
}
public static ConstantTemplate MakeConstantTemplate(Type type, FieldInfo ci, byte index = 0, string customName = null, TypeTemplate typeTemplate = null)
public static ConstantDef MakeConstantDef(Type type, FieldInfo ci, byte index = 0, string customName = null, TypeDef typeDef = null)
{
var annotationAttrs = ci.GetCustomAttributes<AnnotationAttribute>(true);
@@ -106,7 +107,7 @@ public class ConstantTemplate : MemberTemplate
var value = ci.GetValue(null);
if (typeTemplate?.Type == TemplateType.Enum)
if (typeDef?.Type == TypeDefKind.Enum)
value = Convert.ChangeType(value, ci.FieldType.GetEnumUnderlyingType());
Map<string, string> annotations = null;
@@ -120,7 +121,7 @@ public class ConstantTemplate : MemberTemplate
return new ConstantTemplate()
return new ConstantDef()
{
Name = customName,
Index = index,

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Data.Types;
internal class CustomEventOccurredEvent
{
}

View File

@@ -1,5 +1,6 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,9 +9,9 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class EventTemplate : MemberTemplate
public class EventDef : MemberDef
{
public Map<string, string> Annotations
@@ -31,7 +32,7 @@ public class EventTemplate : MemberTemplate
public TRU ArgumentType { get; set; }
public static (uint, EventTemplate) Parse(byte[] data, uint offset, byte index, bool inherited)
public static (uint, EventDef) Parse(byte[] data, uint offset, byte index, bool inherited)
{
var oOffset = offset;
@@ -58,7 +59,7 @@ public class EventTemplate : MemberTemplate
offset += len;
}
return (offset - oOffset, new EventTemplate()
return (offset - oOffset, new EventDef()
{
Index = index,
Name = name,
@@ -102,7 +103,7 @@ public class EventTemplate : MemberTemplate
.ToArray();
}
//public EventTemplate(TypeTemplate template, byte index, string name, bool inherited, TRU argumentType, Map<string, string> annotations = null, bool subscribable = false)
//public EventTemplate(TypeSchema template, byte index, string name, bool inherited, TRU argumentType, Map<string, string> annotations = null, bool subscribable = false)
// : base(template, index, name, inherited)
//{
// this.Annotations = annotations;
@@ -110,7 +111,7 @@ public class EventTemplate : MemberTemplate
// this.ArgumentType = argumentType;
//}
public static EventTemplate MakeEventTemplate(Type type, EventInfo ei, byte index, string name, TypeTemplate typeTemplate)
public static EventDef MakeEventDef(Type type, EventInfo ei, byte index, string name, TypeDef schema)
{
if (!ei.EventHandlerType.IsGenericType)
@@ -171,7 +172,7 @@ public class EventTemplate : MemberTemplate
}
return new EventTemplate()
return new EventDef()
{
Name = name,
ArgumentType = evtType,

View File

@@ -1,6 +1,7 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Net.IIP;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,9 +10,9 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class FunctionTemplate : MemberTemplate
public class FunctionDef : MemberDef
{
public Map<string, string> Annotations
@@ -30,7 +31,7 @@ public class FunctionTemplate : MemberTemplate
public bool IsStatic { get; set; }
public ArgumentTemplate[] Arguments { get; set; }
public ArgumentDef[] Arguments { get; set; }
public MethodInfo MethodInfo
{
@@ -39,7 +40,7 @@ public class FunctionTemplate : MemberTemplate
}
public static (uint, FunctionTemplate) Parse(byte[] data, uint offset, byte index, bool inherited)
public static (uint, FunctionDef) Parse(byte[] data, uint offset, byte index, bool inherited)
{
var oOffset = offset;
@@ -56,11 +57,11 @@ public class FunctionTemplate : MemberTemplate
// arguments count
var argsCount = data[offset++];
List<ArgumentTemplate> arguments = new();
List<ArgumentDef> arguments = new();
for (var a = 0; a < argsCount; a++)
{
var (cs, argType) = ArgumentTemplate.Parse(data, offset, a);
var (cs, argType) = ArgumentDef.Parse(data, offset, a);
arguments.Add(argType);
offset += cs;
}
@@ -78,7 +79,7 @@ public class FunctionTemplate : MemberTemplate
offset += len;
}
return (offset - oOffset, new FunctionTemplate()
return (offset - oOffset, new FunctionDef()
{
Index = index,
Name = name,
@@ -117,7 +118,7 @@ public class FunctionTemplate : MemberTemplate
return bl.ToArray();
}
//public FunctionTemplate(TypeTemplate template, byte index, string name, bool inherited, bool isStatic, ArgumentTemplate[] arguments, TRU returnType, Map<string, string> annotations = null)
//public FunctionTemplate(TypeSchema template, byte index, string name, bool inherited, bool isStatic, ArgumentTemplate[] arguments, TRU returnType, Map<string, string> annotations = null)
// : base(template, index, name, inherited)
//{
// this.Arguments = arguments;
@@ -128,7 +129,7 @@ public class FunctionTemplate : MemberTemplate
public static FunctionTemplate MakeFunctionTemplate(Type type, MethodInfo mi, byte index, string name, TypeTemplate typeTemplate)
public static FunctionDef MakeFunctionDef(Type type, MethodInfo mi, byte index, string name, TypeDef schema)
{
var genericRtType = mi.ReturnType.IsGenericType ? mi.ReturnType.GetGenericTypeDefinition() : null;
@@ -262,7 +263,7 @@ public class FunctionTemplate : MemberTemplate
argAnn.Add(attr.Key, attr.Value);
}
return new ArgumentTemplate()
return new ArgumentDef()
{
Name = x.Name,
Type = argType,
@@ -290,7 +291,7 @@ public class FunctionTemplate : MemberTemplate
}
return new FunctionTemplate()
return new FunctionDef()
{
Name = name,
Index = index,

View File

@@ -1,9 +1,10 @@
using System;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
#nullable enable

View File

@@ -5,14 +5,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Resource.Template;
public class MemberTemplate
namespace Esiur.Data.Types;
public class MemberDef
{
public byte Index { get; set; }
public string Name { get; set; }
public bool Inherited { get; set; }
public TypeTemplate Template { get; set; }
public TypeDef Definition { get; set; }
//public MemberTemplate()
//{
@@ -22,7 +22,7 @@ public class MemberTemplate
// Inherited = inherited;
//}
public string Fullname => Template.ClassName + "." + Name;
public string Fullname => Definition.ClassName + "." + Name;
//public virtual byte[] Compose()
//{

View File

@@ -1,5 +1,6 @@
using Esiur.Data;
using Esiur.Net.IIP;
using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,9 +9,9 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
public class PropertyTemplate : MemberTemplate
public class PropertyDef : MemberDef
{
public Map<string, string> Annotations { get; set; }
@@ -79,7 +80,7 @@ public class PropertyTemplate : MemberTemplate
return $"{Name}: {ValueType}";
}
public static (uint, PropertyTemplate) Parse(byte[] data, uint offset, byte index, bool inherited)
public static (uint, PropertyDef) Parse(byte[] data, uint offset, byte index, bool inherited)
{
var oOffset = offset;
@@ -109,7 +110,7 @@ public class PropertyTemplate : MemberTemplate
offset += len;
}
return (offset - oOffset, new PropertyTemplate()
return (offset - oOffset, new PropertyDef()
{
Index = index,
Name = name,
@@ -192,7 +193,7 @@ public class PropertyTemplate : MemberTemplate
}
}
//public PropertyTemplate(TypeTemplate template, byte index, string name, bool inherited,
//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)
//{
@@ -204,7 +205,7 @@ public class PropertyTemplate : MemberTemplate
// this.ValueType = valueType;
//}
public static PropertyTemplate MakePropertyTemplate(Type type, PropertyInfo pi, string name, byte index, PropertyPermission permission, TypeTemplate typeTemplate)
public static PropertyDef MakePropertyDef(Type type, PropertyInfo pi, string name, byte index, PropertyPermission permission, TypeDef schema)
{
var genericPropType = pi.PropertyType.IsGenericType ? pi.PropertyType.GetGenericTypeDefinition() : null;
@@ -265,7 +266,7 @@ public class PropertyTemplate : MemberTemplate
}
return new PropertyTemplate()
return new PropertyDef()
{
Name = name,
Index = index,
@@ -277,7 +278,7 @@ public class PropertyTemplate : MemberTemplate
Annotations = annotations,
};
//var pt = new PropertyTemplate(typeTemplate, index, customName ?? pi.Name, pi.DeclaringType != type, propType);
//var pt = new PropertyTemplate(TypeSchema, index, customName ?? pi.Name, pi.DeclaringType != type, propType);
//if (storageAttr != null)
// pt.Recordable = storageAttr.Mode == StorageMode.Recordable;

View File

@@ -10,8 +10,9 @@ using System.Security.Cryptography;
using Esiur.Proxy;
using Esiur.Net.IIP;
using System.Runtime.CompilerServices;
using Esiur.Resource;
namespace Esiur.Resource.Template;
namespace Esiur.Data.Types;
//public enum TemplateType
//{
@@ -19,27 +20,27 @@ namespace Esiur.Resource.Template;
// Record
//}
public class TypeTemplate
public class TypeDef
{
protected UUID classId;
protected UUID typeId;
protected UUID? parentId;
public Map<string, string> Annotations { get; set; }
string className;
List<FunctionTemplate> functions = new List<FunctionTemplate>();
List<EventTemplate> events = new List<EventTemplate>();
List<PropertyTemplate> properties = new List<PropertyTemplate>();
List<AttributeTemplate> attributes = new List<AttributeTemplate>();
List<ConstantTemplate> constants = new();
string typeName;
List<FunctionDef> functions = new List<FunctionDef>();
List<EventDef> events = new List<EventDef>();
List<PropertyDef> properties = new List<PropertyDef>();
List<AttributeDef> attributes = new List<AttributeDef>();
List<ConstantDef> constants = new();
int version;
TemplateType templateType;
TypeDefKind typeDefKind;
public override string ToString()
{
return className;
return typeName;
}
// protected TemplateType
@@ -54,7 +55,7 @@ public class TypeTemplate
get { return content; }
}
public TemplateType Type => templateType;
public TypeDefKind Kind => typeDefKind;
public Type DefinedType { get; set; }
@@ -72,7 +73,7 @@ public class TypeTemplate
// return null;
//}
public EventTemplate GetEventTemplateByName(string eventName)
public EventDef GetEventDefByName(string eventName)
{
foreach (var i in events)
if (i.Name == eventName)
@@ -80,7 +81,7 @@ public class TypeTemplate
return null;
}
public EventTemplate GetEventTemplateByIndex(byte index)
public EventDef GetEventDefByIndex(byte index)
{
foreach (var i in events)
if (i.Index == index)
@@ -88,14 +89,14 @@ public class TypeTemplate
return null;
}
public FunctionTemplate GetFunctionTemplateByName(string functionName)
public FunctionDef GetFunctionDefByName(string functionName)
{
foreach (var i in functions)
if (i.Name == functionName)
return i;
return null;
}
public FunctionTemplate GetFunctionTemplateByIndex(byte index)
public FunctionDef GetFunctionDefByIndex(byte index)
{
foreach (var i in functions)
if (i.Index == index)
@@ -103,7 +104,7 @@ public class TypeTemplate
return null;
}
public PropertyTemplate GetPropertyTemplateByIndex(byte index)
public PropertyDef GetPropertyDefByIndex(byte index)
{
foreach (var i in properties)
if (i.Index == index)
@@ -111,7 +112,7 @@ public class TypeTemplate
return null;
}
public PropertyTemplate GetPropertyTemplateByName(string propertyName)
public PropertyDef GetPropertyDefByName(string propertyName)
{
foreach (var i in properties)
if (i.Name == propertyName)
@@ -119,7 +120,7 @@ public class TypeTemplate
return null;
}
public AttributeTemplate GetAttributeTemplate(string attributeName)
public AttributeDef GetAttributeDef(string attributeName)
{
foreach (var i in attributes)
if (i.Name == attributeName)
@@ -127,13 +128,13 @@ public class TypeTemplate
return null;
}
public UUID ClassId
public UUID Id
{
get { return classId; }
get { return typeId; }
}
public string ClassName
public string Name
{
get { return className; }
get { return typeName; }
}
//public MemberTemplate[] Methods
@@ -141,24 +142,24 @@ public class TypeTemplate
// get { return members.ToArray(); }
//}
public FunctionTemplate[] Functions
public FunctionDef[] Functions
{
get { return functions.ToArray(); }
}
public EventTemplate[] Events
public EventDef[] Events
{
get { return events.ToArray(); }
}
public PropertyTemplate[] Properties
public PropertyDef[] Properties
{
get { return properties.ToArray(); }
}
public ConstantTemplate[] Constants => constants.ToArray();
public ConstantDef[] Constants => constants.ToArray();
public TypeTemplate()
public TypeDef()
{
}
@@ -169,7 +170,7 @@ public class TypeTemplate
if (attr != null)
return attr.ClassId;
var tn = Encoding.UTF8.GetBytes(GetTypeClassName(type));
var tn = Encoding.UTF8.GetBytes(GetTypeName(type));
var hash = SHA256.Create().ComputeHash(tn).Clip(0, 16);
hash[6] = (byte)((hash[6] & 0xF) | 0x80);
hash[8] = (byte)((hash[8] & 0xF) | 0x80);
@@ -222,24 +223,24 @@ public class TypeTemplate
}
public static TypeTemplate[] GetDependencies(TypeTemplate template, Warehouse warehouse)
public static TypeDef[] GetDependencies(TypeDef schema, Warehouse warehouse)
{
var list = new List<TypeTemplate>();
var list = new List<TypeDef>();
// Add self
list.Add(template);
list.Add(schema);
Action<TypeTemplate, List<TypeTemplate>> getDependenciesFunc = null;
Action<TypeDef, List<TypeDef>> getDependenciesFunc = null;
getDependenciesFunc = (TypeTemplate tmp, List<TypeTemplate> bag) =>
getDependenciesFunc = (TypeDef sch, List<TypeDef> bag) =>
{
if (template.DefinedType == null)
if (schema.DefinedType == null)
return;
// Add parents
var parentType = tmp.ParentDefinedType;
var parentType = sch.ParentDefinedType;
// Get parents
while (parentType != null)
@@ -253,7 +254,7 @@ public class TypeTemplate
}
// functions
foreach (var f in tmp.functions)
foreach (var f in sch.functions)
{
var functionReturnTypes = GetDistributedTypes(f.MethodInfo.ReturnType);
//.Select(x => Warehouse.GetTemplateByType(x))
@@ -319,7 +320,7 @@ public class TypeTemplate
}
// properties
foreach (var p in tmp.properties)
foreach (var p in sch.properties)
{
var propertyTypes = GetDistributedTypes(p.PropertyInfo.PropertyType);
@@ -338,7 +339,7 @@ public class TypeTemplate
}
// events
foreach (var e in tmp.events)
foreach (var e in sch.events)
{
var eventTypes = GetDistributedTypes(e.EventInfo.EventHandlerType.GenericTypeArguments[0]);
@@ -358,12 +359,12 @@ public class TypeTemplate
}
};
getDependenciesFunc(template, list);
getDependenciesFunc(schema, list);
return list.Distinct().ToArray();
}
public static string GetTypeClassName(Type type, char separator = '.')
public static string GetTypeName(Type type, char separator = '.')
{
if (type.IsGenericType)
@@ -371,7 +372,7 @@ public class TypeTemplate
var index = type.Name.IndexOf("`");
var name = $"{type.Namespace}{separator}{((index > -1) ? type.Name.Substring(0, index) : type.Name)}Of";
foreach (var t in type.GenericTypeArguments)
name += GetTypeClassName(t, '_');
name += GetTypeName(t, '_');
return name;
}
@@ -386,14 +387,14 @@ public class TypeTemplate
public bool IsWrapper { get; private set; }
public TypeTemplate(Type type, Warehouse warehouse = null)
public TypeDef(Type type, Warehouse warehouse = null)
{
if (Codec.ImplementsInterface(type, typeof(IResource)))
templateType = TemplateType.Resource;
typeDefKind = TypeDefKind.Resource;
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
templateType = TemplateType.Record;
typeDefKind = TypeDefKind.Record;
else if (type.IsEnum)
templateType = TemplateType.Enum;
typeDefKind = TypeDefKind.Enum;
else
throw new Exception("Type must implement IResource, IRecord or inherit from DistributedResource.");
@@ -403,13 +404,13 @@ public class TypeTemplate
DefinedType = type;
className = GetTypeClassName(type);
typeName = GetTypeName(type);
// set guid
classId = GetTypeUUID(type);
typeId = GetTypeUUID(type);
if (warehouse != null)
warehouse.PutTemplate(this);
warehouse.RegisterSchema(this);
var hierarchy = GetHierarchy(type);
@@ -417,7 +418,7 @@ public class TypeTemplate
{
foreach (var cd in hierarchy[MemberTypes.Field])
{
constants.Add(ConstantTemplate.MakeConstantTemplate
constants.Add(ConstantDef.MakeConstantDef
(type, (FieldInfo)cd.GetMemberInfo(), cd.Index, cd.Name, this));
}
}
@@ -426,18 +427,18 @@ public class TypeTemplate
{
foreach (var pd in hierarchy[MemberTypes.Property])
{
properties.Add(PropertyTemplate.MakePropertyTemplate
properties.Add(PropertyDef.MakePropertyDef
(type, (PropertyInfo)pd.GetMemberInfo(), pd.Name, pd.Index, pd.PropertyPermission, this));
}
}
if (templateType == TemplateType.Resource)
if (typeDefKind == TypeDefKind.Resource)
{
if (hierarchy.ContainsKey(MemberTypes.Method))
{
foreach (var fd in hierarchy[MemberTypes.Method])
{
functions.Add(FunctionTemplate.MakeFunctionTemplate
functions.Add(FunctionDef.MakeFunctionDef
(type, (MethodInfo)fd.GetMemberInfo(), fd.Index, fd.Name, this));
}
}
@@ -446,7 +447,7 @@ public class TypeTemplate
{
foreach (var ed in hierarchy[MemberTypes.Event])
{
events.Add(EventTemplate.MakeEventTemplate
events.Add(EventDef.MakeEventDef
(type, (EventInfo)ed.GetMemberInfo(), ed.Index, ed.Name, this));
}
}
@@ -461,8 +462,8 @@ public class TypeTemplate
{
var attrAttr = attr.GetCustomAttribute<AttributeAttribute>();
attributes.Add(AttributeTemplate
.MakeAttributeTemplate(type, attr, 0, attrAttr?.Name ?? attr.Name, this));
attributes.Add(AttributeDef
.MakeAttributeDef(type, attr, 0, attrAttr?.Name ?? attr.Name, this));
}
@@ -478,12 +479,12 @@ public class TypeTemplate
var hasClassAnnotation = (classAnnotations != null) && (classAnnotations.Count() > 0);
var classNameBytes = DC.ToBytes(className);
var typeNameBytes = DC.ToBytes(typeName);
b.AddUInt8((byte)((hasParent ? 0x80 : 0) | (hasClassAnnotation ? 0x40 : 0x0) | (byte)templateType))
.AddUUID(classId)
.AddUInt8((byte)classNameBytes.Length)
.AddUInt8Array(classNameBytes);
b.AddUInt8((byte)((hasParent ? 0x80 : 0) | (hasClassAnnotation ? 0x40 : 0x0) | (byte)typeDefKind))
.AddUUID(typeId)
.AddUInt8((byte)typeNameBytes.Length)
.AddUInt8Array(typeNameBytes);
if (hasParent)
{
@@ -529,7 +530,7 @@ public class TypeTemplate
while (parent != null)
{
if (parent == typeof(Resource)
if (parent == typeof(Esiur.Resource.Resource)
|| parent == typeof(Record)
|| parent == typeof(EntryPoint))
return false;
@@ -606,7 +607,7 @@ public class TypeTemplate
type = type.BaseType;
if (type == null
|| type == typeof(Resource)
|| type == typeof(Esiur.Resource.Resource)
|| type == typeof(Record)
|| type == typeof(EntryPoint))
break;
@@ -674,13 +675,13 @@ public class TypeTemplate
}
public static TypeTemplate Parse(byte[] data)
public static TypeDef Parse(byte[] data)
{
return Parse(data, 0, (uint)data.Length);
}
public static TypeTemplate Parse(byte[] data, uint offset, uint contentLength)
public static TypeDef Parse(byte[] data, uint offset, uint contentLength)
{
uint ends = offset + contentLength;
@@ -689,17 +690,17 @@ public class TypeTemplate
// start parsing...
var od = new TypeTemplate();
var od = new TypeDef();
od.content = data.Clip(offset, contentLength);
var hasParent = (data[offset] & 0x80) > 0;
var hasClassAnnotation = (data[offset] & 0x40) > 0;
od.templateType = (TemplateType)(data[offset++] & 0xF);
od.typeDefKind = (TypeDefKind)(data[offset++] & 0xF);
od.classId = data.GetUUID(offset);
od.typeId = data.GetUUID(offset);
offset += 16;
od.className = data.GetString(offset + 1, data[offset]);
od.typeName = data.GetString(offset + 1, data[offset]);
offset += (uint)data[offset] + 1;
@@ -736,27 +737,27 @@ public class TypeTemplate
if (type == 0) // function
{
var (len, ft) = FunctionTemplate.Parse(data, offset, functionIndex++, inherited);
var (len, ft) = FunctionDef.Parse(data, offset, functionIndex++, inherited);
offset += len;
od.functions.Add(ft);
}
else if (type == 1) // property
{
var (len, pt) = PropertyTemplate.Parse(data, offset, propertyIndex++, inherited);
var (len, pt) = PropertyDef.Parse(data, offset, propertyIndex++, inherited);
offset += len;
od.properties.Add(pt);
}
else if (type == 2) // Event
{
var (len, et) = EventTemplate.Parse(data, offset, propertyIndex++, inherited);
var (len, et) = EventDef.Parse(data, offset, propertyIndex++, inherited);
offset += len;
od.events.Add(et);
}
// constant
else if (type == 3)
{
var (len, ct) = ConstantTemplate.Parse(data, offset, propertyIndex++, inherited);
var (len, ct) = ConstantDef.Parse(data, offset, propertyIndex++, inherited);
offset += len;
od.constants.Add(ct);
}
@@ -770,7 +771,7 @@ public class TypeTemplate
var rt = new Map<byte, object>();
foreach (var kv in properties)
{
var pt = GetPropertyTemplateByName(kv.Key);
var pt = GetPropertyDefByName(kv.Key);
if (pt == null) continue;
rt.Add(pt.Index, kv.Value);
}

View File

@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System.Text;
namespace Esiur.Resource.Template;
public enum TemplateType : byte
namespace Esiur.Data.Types;
public enum TypeDefKind : byte
{
Resource,
Record,

View File

@@ -67,6 +67,8 @@
<None Include="Data\DataDeserializer - Copy.cs" />
<None Include="Data\NullabilityInfo.cs" />
<None Include="Data\NullabilityInfoContext.cs" />
<None Include="Data\Types\ArgumentDef.cs" />
<None Include="Data\Types\AttributeDef.cs" />
<None Include="LICENSE" Pack="true" PackagePath=""></None>
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>

View File

@@ -24,13 +24,13 @@ SOFTWARE.
using Esiur.Core;
using Esiur.Data;
using Esiur.Data.Schema;
using Esiur.Misc;
using Esiur.Net.HTTP;
using Esiur.Net.Packets;
using Esiur.Net.Packets.HTTP;
using Esiur.Net.Sockets;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using Esiur.Security.Membership;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -492,19 +492,19 @@ public partial class DistributedConnection : NetworkConnection, IStore
IIPRequestUnsubscribe(packet.CallbackId, dt, msg);
break;
// Inquire
case IIPPacketRequest.TemplateFromClassName:
case IIPPacketRequest.SchemaFromClassName:
IIPRequestTemplateFromClassName(packet.CallbackId, dt, msg);
break;
case IIPPacketRequest.TemplateFromClassId:
case IIPPacketRequest.SchemaFromClassId:
IIPRequestTemplateFromClassId(packet.CallbackId, dt, msg);
break;
case IIPPacketRequest.TemplateFromResourceId:
case IIPPacketRequest.SchemaFromResourceId:
IIPRequestTemplateFromResourceId(packet.CallbackId, dt, msg);
break;
case IIPPacketRequest.Query:
IIPRequestQueryResources(packet.CallbackId, dt, msg);
break;
case IIPPacketRequest.LinkTemplates:
case IIPPacketRequest.LinkSchemas:
IIPRequestLinkTemplates(packet.CallbackId, dt, msg);
break;
case IIPPacketRequest.Token:
@@ -1712,7 +1712,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
throw new NotImplementedException();
}
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{
throw new NotImplementedException();
}

View File

@@ -24,10 +24,10 @@ SOFTWARE.
using Esiur.Core;
using Esiur.Data;
using Esiur.Data.Types;
using Esiur.Misc;
using Esiur.Net.Packets;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using Esiur.Security.Permissions;
using System;
@@ -50,12 +50,12 @@ partial class DistributedConnection
KeyList<uint, WeakReference<DistributedResource>> suspendedResources = new KeyList<uint, WeakReference<DistributedResource>>();
KeyList<uint, DistributedResourceAttachRequestInfo> resourceRequests = new KeyList<uint, DistributedResourceAttachRequestInfo>();
KeyList<UUID, AsyncReply<TypeTemplate>> templateRequests = new KeyList<UUID, AsyncReply<TypeTemplate>>();
KeyList<UUID, AsyncReply<TypeDef>> typeDefsByIdRequests = new KeyList<UUID, AsyncReply<TypeDef>>();
KeyList<string, AsyncReply<TypeTemplate>> templateByNameRequests = new KeyList<string, AsyncReply<TypeTemplate>>();
KeyList<string, AsyncReply<TypeDef>> typeDefsByNameRequests = new KeyList<string, AsyncReply<TypeDef>>();
Dictionary<UUID, TypeTemplate> templates = new Dictionary<UUID, TypeTemplate>();
Dictionary<UUID, TypeDef> typeDefs = new Dictionary<UUID, TypeDef>();
KeyList<uint, AsyncReply> requests = new KeyList<uint, AsyncReply>();
@@ -455,7 +455,7 @@ partial class DistributedConnection
Fetch(rid, null).Then(r =>
{
var pt = r.Instance.Template.GetPropertyTemplateByIndex(index);
var pt = r.Instance.Definition.GetPropertyDefByIndex(index);
if (pt == null)
return;
@@ -500,7 +500,7 @@ partial class DistributedConnection
Fetch(resourceId, null).Then(r =>
{
var et = r.Instance.Template.GetEventTemplateByIndex(index);
var et = r.Instance.Definition.GetEventDefByIndex(index);
if (et == null) // this should never happen
return;
@@ -561,7 +561,7 @@ partial class DistributedConnection
// reply ok
SendReply(IIPPacketReply.Completed, callback,
r.Instance.Template.ClassId,
r.Instance.Definition.TypeId,
r.Instance.Age,
r.Instance.Link,
r.Instance.Hops,
@@ -608,7 +608,7 @@ partial class DistributedConnection
// reply ok
SendReply(IIPPacketReply.Completed, callback,
r.Instance.Template.ClassId,
r.Instance.Definition.TypeId,
r.Instance.Age,
r.Instance.Link,
r.Instance.Hops,
@@ -666,12 +666,12 @@ partial class DistributedConnection
var path = (string)args[0];
TypeTemplate type = null;
TypeDef type = null;
if (args[1] is UUID)
type = Instance.Warehouse.GetTemplateByClassId((UUID)args[1]);
type = Instance.Warehouse.GetTypeDefById((UUID)args[1]);
else if (args[1] is string)
type = Instance.Warehouse.GetTemplateByClassName((string)args[1]);
type = Instance.Warehouse.GetTypeByName((string)args[1]);
if (type == null)
{
@@ -814,7 +814,7 @@ partial class DistributedConnection
return;
}
var templates = TypeTemplate.GetDependencies(r.Instance.Template, Instance.Warehouse);
var templates = TypeDef.GetDependencies(r.Instance.Definition, Instance.Warehouse);
// Send
SendReply(IIPPacketReply.Completed, callback, templates.Select(x => x.Content).ToArray());
@@ -842,18 +842,18 @@ partial class DistributedConnection
else
{
// reply failed
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TemplateNotFound);
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TypeDefNotFound);
}
}
void IIPRequestTemplateFromClassId(uint callback, ParsedTDU dataType, byte[] data)
void IIPRequestTypeDefById(uint callback, ParsedTDU dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
var classId = (UUID)value;
var t = Instance.Warehouse.GetTemplateByClassId(classId);
var t = Instance.Warehouse.GetTypeDefById(classId);
if (t != null)
{
@@ -862,7 +862,7 @@ partial class DistributedConnection
else
{
// reply failed
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TemplateNotFound);
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TypeDefNotFound);
}
}
@@ -879,7 +879,7 @@ partial class DistributedConnection
{
if (r != null)
{
SendReply(IIPPacketReply.Completed, callback, r.Instance.Template.Content);
SendReply(IIPPacketReply.Completed, callback, r.Instance.Definition.Content);
}
else
{
@@ -1046,16 +1046,16 @@ partial class DistributedConnection
var index = (byte)args[1];
var template = Instance.Warehouse.GetTemplateByClassId(classId);
var template = Instance.Warehouse.GetTypeDefById(classId);
if (template == null)
{
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TemplateNotFound);
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.TypeDefNotFound);
return;
}
var ft = template.GetFunctionTemplateByIndex(index);
var ft = template.GetFunctionDefByIndex(index);
if (ft == null)
{
@@ -1131,7 +1131,7 @@ partial class DistributedConnection
return;
}
var ft = r.Instance.Template.GetFunctionTemplateByIndex(index);
var ft = r.Instance.Definition.GetFunctionDefByIndex(index);
if (ft == null)
{
@@ -1221,7 +1221,7 @@ partial class DistributedConnection
void InvokeFunction(FunctionTemplate ft, uint callback, object arguments, IIPPacketRequest actionType, object target = null)
void InvokeFunction(FunctionDef ft, uint callback, object arguments, IIPPacketRequest actionType, object target = null)
{
// cast arguments
@@ -1455,7 +1455,7 @@ partial class DistributedConnection
return;
}
var et = r.Instance.Template.GetEventTemplateByIndex(index);
var et = r.Instance.Definition.GetEventDefByIndex(index);
if (et != null)
{
@@ -1514,7 +1514,7 @@ partial class DistributedConnection
return;
}
var et = r.Instance.Template.GetEventTemplateByIndex(index);
var et = r.Instance.Definition.GetEventDefByIndex(index);
if (et == null)
{
@@ -1578,7 +1578,7 @@ partial class DistributedConnection
return;
}
var pt = r.Instance.Template.GetPropertyTemplateByIndex(index);
var pt = r.Instance.Definition.GetPropertyDefByIndex(index);
if (pt != null)
{
@@ -1686,27 +1686,27 @@ partial class DistributedConnection
/// <summary>
/// Get the ResourceTemplate for a given class Id.
/// Get the TypeSchema for a given class Id.
/// </summary>
/// <param name="classId">Class GUID.</param>
/// <returns>ResourceTemplate.</returns>
public AsyncReply<TypeTemplate> GetTemplate(UUID classId)
/// <returns>TypeSchema.</returns>
public AsyncReply<TypeDef> GetTypeDefById(UUID classId)
{
if (templates.ContainsKey(classId))
return new AsyncReply<TypeTemplate>(templates[classId]);
else if (templateRequests.ContainsKey(classId))
return templateRequests[classId];
if (typeDefs.ContainsKey(classId))
return new AsyncReply<TypeDef>(typeDefs[classId]);
else if (typeDefsByIdRequests.ContainsKey(classId))
return typeDefsByIdRequests[classId];
var reply = new AsyncReply<TypeTemplate>();
templateRequests.Add(classId, reply);
var reply = new AsyncReply<TypeDef>();
typeDefsByIdRequests.Add(classId, reply);
SendRequest(IIPPacketRequest.TemplateFromClassId, classId)
SendRequest(IIPPacketRequest.SchemaFromClassId, classId)
.Then((result) =>
{
var tt = TypeTemplate.Parse((byte[])result);
templateRequests.Remove(classId);
templates.Add(tt.ClassId, tt);
Instance.Warehouse.PutTemplate(tt);
var tt = TypeDef.Parse((byte[])result);
typeDefsByIdRequests.Remove(classId);
typeDefs.Add(tt.ClassId, tt);
Instance.Warehouse.RegisterSchema(tt);
reply.Trigger(tt);
}).Error((ex) =>
@@ -1718,27 +1718,27 @@ partial class DistributedConnection
}
public AsyncReply<TypeTemplate> GetTemplateByClassName(string className)
public AsyncReply<TypeDef> GetTypeDefByClassName(string className)
{
var template = templates.Values.FirstOrDefault(x => x.ClassName == className);
var template = typeDefs.Values.FirstOrDefault(x => x.ClassName == className);
if (template != null)
return new AsyncReply<TypeTemplate>(template);
return new AsyncReply<TypeDef>(template);
if (templateByNameRequests.ContainsKey(className))
return templateByNameRequests[className];
if (typeDefsByNameRequests.ContainsKey(className))
return typeDefsByNameRequests[className];
var reply = new AsyncReply<TypeTemplate>();
templateByNameRequests.Add(className, reply);
var reply = new AsyncReply<TypeDef>();
typeDefsByNameRequests.Add(className, reply);
SendRequest(IIPPacketRequest.TemplateFromClassName, className)
SendRequest(IIPPacketRequest.SchemaFromClassName, className)
.Then((result) =>
{
var tt = TypeTemplate.Parse((byte[])result);
var tt = TypeDef.Parse((byte[])result);
templateByNameRequests.Remove(className);
templates.Add(tt.ClassId, tt);
Instance.Warehouse.PutTemplate(tt);
typeDefsByNameRequests.Remove(className);
typeDefs.Add(tt.ClassId, tt);
Instance.Warehouse.RegisterSchema(tt);
reply.Trigger(tt);
}).Error((ex) =>
{
@@ -1786,23 +1786,23 @@ partial class DistributedConnection
}
public AsyncReply<TypeTemplate[]> GetLinkTemplates(string link)
public AsyncReply<TypeDef[]> GetLinkDefinitions(string link)
{
var reply = new AsyncReply<TypeTemplate[]>();
var reply = new AsyncReply<TypeDef[]>();
SendRequest(IIPPacketRequest.LinkTemplates, link)
SendRequest(IIPPacketRequest.LinkSchemas, link)
.Then((result) =>
{
var templates = new List<TypeTemplate>();
var defs = new List<TypeDef>();
foreach (var template in (byte[][])result)
foreach (var def in (byte[][])result)
{
templates.Add(TypeTemplate.Parse(template));
defs.Add(TypeDef.Parse(def));
}
reply.Trigger(templates.ToArray());
reply.Trigger(defs.ToArray());
}).Error((ex) =>
{
@@ -1874,7 +1874,7 @@ partial class DistributedConnection
// ClassId, Age, Link, Hops, PropertyValue[]
var args = (object[])result;
var classId = (UUID)args[0];
var typeId = (UUID)args[0];
var age = Convert.ToUInt64(args[1]);
var link = (string)args[2];
var hops = (byte)args[3];
@@ -1882,20 +1882,20 @@ partial class DistributedConnection
DistributedResource dr;
TypeTemplate template = null;
TypeDef typeDef = null;
if (resource == null)
{
template = Instance.Warehouse.GetTemplateByClassId(classId, TemplateType.Resource);
if (template?.DefinedType != null && template.IsWrapper)
dr = Activator.CreateInstance(template.DefinedType, this, id, Convert.ToUInt64(args[1]), (string)args[2]) as DistributedResource;
typeDef = Instance.Warehouse.GetTypeDefByClassId(typeId, TypeDefKind.Resource);
if (typeDef?.DefinedType != null && typeDef.IsWrapper)
dr = Activator.CreateInstance(typeDef.DefinedType, this, id, Convert.ToUInt64(args[1]), (string)args[2]) as DistributedResource;
else
dr = new DistributedResource(this, id, Convert.ToUInt64(args[1]), (string)args[2]);
}
else
{
dr = resource;
template = resource.Instance.Template;
typeDef = resource.Instance.Definition;
}
@@ -1924,14 +1924,14 @@ partial class DistributedConnection
};
if (template == null)
if (typeDef == null)
{
GetTemplate(classId).Then((tmp) =>
GetTypeDefById(typeId).Then((tmp) =>
{
// ClassId, ResourceAge, ResourceLink, Content
if (resource == null)
{
dr.ResourceTemplate = tmp;
dr.ResourceDefinition = tmp;
Instance.Warehouse.Put(this.Instance.Link + "/" + id.ToString(), dr)
.Then(initResource)
@@ -1999,7 +1999,7 @@ partial class DistributedConnection
/// <param name="properties">Values for the resource properties.</param>
/// <param name="attributes">Resource attributes.</param>
/// <returns>New resource instance</returns>
public AsyncReply<DistributedResource> Create(string path, TypeTemplate type, Map<string, object> properties, Map<string, object> attributes)
public AsyncReply<DistributedResource> Create(string path, TypeDef type, Map<string, object> properties, Map<string, object> attributes)
{
var reply = new AsyncReply<DistributedResource>();
@@ -2103,7 +2103,7 @@ partial class DistributedConnection
private void Instance_EventOccurred(EventOccurredInfo info)
{
if (info.EventTemplate.Subscribable)
if (info.Definition.Subscribable)
{
lock (subscriptionsLock)
{
@@ -2111,18 +2111,18 @@ partial class DistributedConnection
if (!subscriptions.ContainsKey(info.Resource))
return;
if (!subscriptions[info.Resource].Contains(info.EventTemplate.Index))
if (!subscriptions[info.Resource].Contains(info.Definition.Index))
return;
}
}
if (info.Resource.Instance.Applicable(this.session, ActionType.ReceiveEvent, info.EventTemplate, null) == Ruling.Denied)
if (info.Resource.Instance.Applicable(this.session, ActionType.ReceiveEvent, info.Definition, null) == Ruling.Denied)
return;
// compose the packet
SendNotification(IIPPacketNotification.EventOccurred,
info.Resource.Instance.Id,
info.EventTemplate.Index,
info.Definition.Index,
info.Value);
}

View File

@@ -40,8 +40,8 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Net.Packets;
using Esiur.Data.Types;
namespace Esiur.Net.IIP;
@@ -57,7 +57,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
public event PropertyChangedEventHandler PropertyChanged;
uint instanceId;
TypeTemplate template;
TypeDef typeDef;
DistributedConnection connection;
@@ -163,7 +163,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
this.properties = new object[properties.Length];
this.events = new DistributedResourceEvent[Instance.Template.Events.Length];
this.events = new DistributedResourceEvent[Instance.Definition.Events.Length];
for (byte i = 0; i < properties.Length; i++)
{
@@ -187,7 +187,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
protected internal virtual void _EmitEventByIndex(byte index, object args)
{
var et = Instance.Template.GetEventTemplateByIndex(index);
var et = Instance.Definition.GetEventDefByIndex(index);
events[index]?.Invoke(this, args);
Instance.EmitResourceEvent(et, args);
}
@@ -200,21 +200,21 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
if (suspended)
throw new Exception("Trying to access a suspended object.");
if (index >= Instance.Template.Functions.Length)
if (index >= Instance.Definition.Functions.Length)
throw new Exception("Function index is incorrect.");
var ft = Instance.Template.GetFunctionTemplateByIndex(index);
var ft = Instance.Definition.GetFunctionDefByIndex(index);
if (ft == null)
throw new Exception("Function template not found.");
if (ft.IsStatic)
return connection.StaticCall(Instance.Template.ClassId, index, args);
return connection.StaticCall(Instance.Definition.ClassId, index, args);
else
return connection.SendInvoke(instanceId, index, args);
}
public AsyncReply Subscribe(EventTemplate et)
public AsyncReply Subscribe(EventDef et)
{
if (et == null)
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
@@ -227,13 +227,13 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
public AsyncReply Subscribe(string eventName)
{
var et = Instance.Template.GetEventTemplateByName(eventName);
var et = Instance.Definition.GetEventDefByName(eventName);
return Subscribe(et);
}
public AsyncReply Unsubscribe(EventTemplate et)
public AsyncReply Unsubscribe(EventDef et)
{
if (et == null)
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
@@ -246,7 +246,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
public AsyncReply Unsubscribe(string eventName)
{
var et = Instance.Template.GetEventTemplateByName(eventName);
var et = Instance.Definition.GetEventDefByName(eventName);
return Unsubscribe(et);
}
@@ -260,7 +260,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
if (suspended)
throw new Exception("Trying to access a suspended object.");
var ft = Instance.Template.GetFunctionTemplateByName(binder.Name);
var ft = Instance.Definition.GetFunctionDefByName(binder.Name);
var reply = new AsyncReply<object>();
@@ -345,7 +345,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
if (!attached)
return false;
var pt = Instance.Template.GetPropertyTemplateByName(binder.Name);
var pt = Instance.Definition.GetPropertyDefByName(binder.Name);
if (pt != null)
{
@@ -354,7 +354,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
}
else
{
var et = Instance.Template.GetEventTemplateByName(binder.Name);
var et = Instance.Definition.GetEventDefByName(binder.Name);
if (et == null)
return false;
@@ -367,7 +367,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
internal void _UpdatePropertyByIndex(byte index, object value)
{
var pt = Instance.Template.GetPropertyTemplateByIndex(index);
var pt = Instance.Definition.GetPropertyDefByIndex(index);
properties[index] = value;
Instance.EmitModification(pt, value);
}
@@ -403,7 +403,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
if (!attached)
return false;
var pt = Instance.Template.GetPropertyTemplateByName(binder.Name);
var pt = Instance.Definition.GetPropertyDefByName(binder.Name);
if (pt != null)
{
@@ -412,7 +412,7 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
}
else
{
var et = Instance.Template.GetEventTemplateByName(binder.Name);
var et = Instance.Definition.GetEventDefByName(binder.Name);
if (et == null)
return false;
@@ -433,15 +433,15 @@ public class DistributedResource : DynamicObject, IResource, INotifyPropertyChan
set;
}
public TypeTemplate ResourceTemplate
public TypeDef ResourceDefinition
{
get
{
return template;
return typeDef;
}
internal set
{
template = value;
typeDef = value;
}
}

View File

@@ -35,7 +35,7 @@ using System.Net;
using Esiur.Resource;
using Esiur.Security.Membership;
using System.Threading.Tasks;
using Esiur.Resource.Template;
using Esiur.Data.Schema;
namespace Esiur.Net.IIP;
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
@@ -168,13 +168,13 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
public struct CallInfo
{
public FunctionTemplate Template;
public FunctionDefinition Template;
public Delegate Delegate;
}
public DistributedServer MapCall(string call, Delegate handler)
{
var ft = FunctionTemplate.MakeFunctionTemplate(null, handler.Method, 0, call, null);
var ft = FunctionDefinition.MakeFunctionDef(null, handler.Method, 0, call, null);
Calls.Add(call, new CallInfo() { Delegate = handler, Template = ft });
return this;
}

View File

@@ -27,7 +27,7 @@ using System.Text;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Data.Schema;
namespace Esiur.Net.IIP;

View File

@@ -10,11 +10,11 @@ struct IIPPacketAttachInfo
public string Link;
public ulong Age;
public byte[] Content;
public UUID ClassId;
public UUID TypeId;
public IIPPacketAttachInfo(UUID classId, ulong age, string link, byte[] content)
public IIPPacketAttachInfo(UUID typeId, ulong age, string link, byte[] content)
{
ClassId = classId;
TypeId = typeId;
Age = age;
Content = content;
Link = link;

View File

@@ -13,11 +13,11 @@ namespace Esiur.Net.Packets
Unsubscribe = 0x3,
// Request Inquire
TemplateFromClassName = 0x8,
TemplateFromClassId = 0x9,
TemplateFromResourceId = 0xA,
SchemaFromClassName = 0x8,
SchemaFromClassId = 0x9,
SchemaFromResourceId = 0xA,
Query = 0xB,
LinkTemplates = 0xC,
LinkSchemas = 0xC,
Token = 0xD,
GetResourceIdByLink = 0xE,

View File

@@ -4,9 +4,9 @@
// ================================
using Esiur.Core;
using Esiur.Data;
using Esiur.Data.Types;
using Esiur.Net.IIP;
using Esiur.Resource;
using Esiur.Resource.Template;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -57,7 +57,7 @@ namespace Esiur.Proxy
var parts = TemplateGenerator.urlRegex.Split(path);
var con = Warehouse.Default.Get<DistributedConnection>($"{parts[1]}://{parts[2]}").Wait(20000);
var templates = con.GetLinkTemplates(parts[3]).Wait(60000);
var templates = con.GetLinkDefinitions(parts[3]).Wait(60000);
EmitTemplates(spc, templates);
}
@@ -222,26 +222,26 @@ $@" public partial class {ci.Name} : IResource {{
}
// === Emission helpers (ported from your original generator) ===
private static void EmitTemplates(SourceProductionContext spc, TypeTemplate[] templates)
private static void EmitTemplates(SourceProductionContext spc, TypeDef[] templates)
{
foreach (var tmp in templates)
{
if (tmp.Type == TemplateType.Resource)
if (tmp.Kind == TypeDefKind.Resource)
{
var source = TemplateGenerator.GenerateClass(tmp, templates, false);
spc.AddSource(tmp.ClassName + ".g.cs", source);
spc.AddSource(tmp.Name + ".g.cs", source);
}
else if (tmp.Type == TemplateType.Record)
else if (tmp.Kind == TypeDefKind.Record)
{
var source = TemplateGenerator.GenerateRecord(tmp, templates);
spc.AddSource(tmp.ClassName + ".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[] { " +
string.Join(",", templates.Where(x => x.Type == TemplateType.Resource).Select(x => $"typeof({x.ClassName})"))
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.ClassName})"))
+ " }; \r\n public static Type[] Records { get; } = new Type[] { " +
string.Join(",", templates.Where(x => x.Type == TemplateType.Record).Select(x => $"typeof({x.ClassName})"))
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.ClassName})"))
+ " }; " +
"\r\n } \r\n}";

View File

@@ -1,5 +1,4 @@
using Esiur.Data;
using Esiur.Resource.Template;
using System;
using System.Collections.Generic;
using System.IO;
@@ -9,6 +8,7 @@ using System.Text.RegularExpressions;
using Esiur.Resource;
using Esiur.Net.IIP;
using System.Diagnostics;
using Esiur.Data.Types;
namespace Esiur.Proxy;
@@ -61,9 +61,9 @@ public static class TemplateGenerator
}
internal static string GenerateRecord(TypeTemplate template, TypeTemplate[] templates)
internal static string GenerateRecord(TypeDef typeDef, TypeDef[] templates)
{
var cls = template.ClassName.Split('.');
var cls = typeDef.Name.Split('.');
var nameSpace = string.Join(".", cls.Take(cls.Length - 1));
var className = cls.Last();
@@ -74,19 +74,19 @@ public static class TemplateGenerator
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
rt.AppendLine($"namespace {nameSpace} {{");
if (template.Annotations != null)
if (typeDef.Annotations != null)
{
foreach (var ann in template.Annotations)
foreach (var ann in typeDef.Annotations)
{
rt.AppendLine($"[Annotation({ToLiteral(ann.Key)}, {ToLiteral(ann.Value)})]");
}
}
rt.AppendLine($"[ClassId(\"{template.ClassId.Data.ToHex(0, 16, null)}\")]");
rt.AppendLine($"[ClassId(\"{typeDef.Id.Data.ToHex(0, 16, null)}\")]");
rt.AppendLine($"[Export] public class {className} : IRecord {{");
foreach (var p in template.Properties)
foreach (var p in typeDef.Properties)
{
var ptTypeName = GetTypeName(p.ValueType, templates);
@@ -109,9 +109,9 @@ public static class TemplateGenerator
return rt.ToString();
}
internal static string GenerateEnum(TypeTemplate template, TypeTemplate[] templates)
internal static string GenerateEnum(TypeDef template, TypeDef[] templates)
{
var cls = template.ClassName.Split('.');
var cls = template.Name.Split('.');
var nameSpace = string.Join(".", cls.Take(cls.Length - 1));
var className = cls.Last();
@@ -129,7 +129,7 @@ public static class TemplateGenerator
}
}
rt.AppendLine($"[ClassId(\"{template.ClassId.Data.ToHex(0, 16, null)}\")]");
rt.AppendLine($"[ClassId(\"{template.Id.Data.ToHex(0, 16, null)}\")]");
rt.AppendLine($"[Export] public enum {className} {{");
rt.AppendLine(String.Join(",\r\n", template.Constants.Select(x => $"{x.Name}={x.Value}")));
@@ -140,16 +140,16 @@ public static class TemplateGenerator
}
static string GetTypeName(TRU representationType, TypeTemplate[] templates)
static string GetTypeName(TRU representationType, TypeDef[] templates)
{
string name;
if (representationType.Identifier == TRUIdentifier.TypedResource)// == DataType.Resource)
name = templates.First(x => x.ClassId == representationType.UUID && (x.Type == TemplateType.Resource)).ClassName;
name = templates.First(x => x.Id == representationType.UUID && (x.Kind == TypeDefKind.Resource)).Name;
else if (representationType.Identifier == TRUIdentifier.TypedRecord)
name = templates.First(x => x.ClassId == representationType.UUID && x.Type == TemplateType.Record).ClassName;
name = templates.First(x => x.Id == representationType.UUID && x.Kind == TypeDefKind.Record).Name;
else if (representationType.Identifier == TRUIdentifier.Enum)
name = templates.First(x => x.ClassId == representationType.UUID && x.Type == TemplateType.Enum).ClassName;
name = templates.First(x => x.Id == representationType.UUID && x.Kind == TypeDefKind.Enum).Name;
else if (representationType.Identifier == TRUIdentifier.TypedList)
name = GetTypeName(representationType.SubTypes[0], templates) + "[]";
else if (representationType.Identifier == TRUIdentifier.TypedMap)
@@ -215,7 +215,7 @@ public static class TemplateGenerator
if (string.IsNullOrEmpty(dir))
dir = path[2].Replace(":", "_");
var templates = con.GetLinkTemplates(path[3]).Wait(60000);
var templates = con.GetLinkDefinitions(path[3]).Wait(60000);
// no longer needed
Warehouse.Default.Remove(con);
@@ -233,20 +233,20 @@ public static class TemplateGenerator
// make sources
foreach (var tmp in templates)
{
if (tmp.Type == TemplateType.Resource)
if (tmp.Kind == TypeDefKind.Resource)
{
var source = GenerateClass(tmp, templates, asyncSetters);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.ClassName + ".g.cs", source);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.Name + ".g.cs", source);
}
else if (tmp.Type == TemplateType.Record)
else if (tmp.Kind == TypeDefKind.Record)
{
var source = GenerateRecord(tmp, templates);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.ClassName + ".g.cs", source);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.Name + ".g.cs", source);
}
else if (tmp.Type == TemplateType.Enum)
else if (tmp.Kind == TypeDefKind.Enum)
{
var source = GenerateEnum(tmp, templates);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.ClassName + ".g.cs", source);
File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + tmp.Name + ".g.cs", source);
}
}
@@ -256,13 +256,13 @@ public static class TemplateGenerator
namespace Esiur {
public static class Generated {
public static Type[] Resources {get;} = new Type[] { " +
string.Join(",", templates.Where(x => x.Type == TemplateType.Resource).Select(x => $"typeof({x.ClassName})"))
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.Name})"))
+ @" };
public static Type[] Records { get; } = new Type[] { " +
string.Join(",", templates.Where(x => x.Type == TemplateType.Record).Select(x => $"typeof({x.ClassName})"))
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.Name})"))
+ @" };
public static Type[] Enums { get; } = new Type[] { " +
string.Join(",", templates.Where(x => x.Type == TemplateType.Enum).Select(x => $"typeof({x.ClassName})"))
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Enum).Select(x => $"typeof({x.Name})"))
+ @" };" +
"\r\n } \r\n}";
@@ -279,9 +279,9 @@ public static class TemplateGenerator
}
}
internal static string GenerateClass(TypeTemplate template, TypeTemplate[] templates, bool asyncSetters)
internal static string GenerateClass(TypeDef template, TypeDef[] templates, bool asyncSetters)
{
var cls = template.ClassName.Split('.');
var cls = template.Name.Split('.');
var nameSpace = string.Join(".", cls.Take(cls.Length - 1));
var className = cls.Last();
@@ -302,13 +302,13 @@ public static class TemplateGenerator
}
rt.AppendLine($"[ClassId(\"{template.ClassId.Data.ToHex(0, 16, null)}\")]");
rt.AppendLine($"[ClassId(\"{template.Id.Data.ToHex(0, 16, null)}\")]");
// extends
if (template.ParentId == null)
rt.AppendLine($"public class {className} : DistributedResource {{");
else
rt.AppendLine($"public class {className} : {templates.First(x => x.ClassId == template.ParentId && x.Type == TemplateType.Resource).ClassName} {{");
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) {{}}");
@@ -378,7 +378,7 @@ public static class TemplateGenerator
rt.AppendLine($"var rt = new AsyncReply<{rtTypeName}>();");
if (f.IsStatic)
rt.AppendLine($"connection.StaticCall(Guid.Parse(\"{template.ClassId.ToString()}\"), {f.Index}, args)");
rt.AppendLine($"connection.StaticCall(Guid.Parse(\"{template.Id.ToString()}\"), {f.Index}, args)");
else
rt.AppendLine($"_Invoke({f.Index}, args)");

View File

@@ -1,4 +1,4 @@
using Esiur.Resource.Template;
using Esiur.Data.Types;
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
@@ -8,7 +8,7 @@ namespace Esiur.Resource;
public class CustomEventOccurredInfo
{
public readonly EventTemplate EventTemplate;
public readonly EventDef EventTemplate;
public readonly IResource Resource;
public readonly object Value;
public readonly object Issuer;
@@ -16,7 +16,7 @@ public class CustomEventOccurredInfo
public string Name => EventTemplate.Name;
public CustomEventOccurredInfo(IResource resource, EventTemplate eventTemplate, Func<Session, bool> receivers, object issuer, object value)
public CustomEventOccurredInfo(IResource resource, EventDef eventTemplate, Func<Session, bool> receivers, object issuer, object value)
{
Resource = resource;
EventTemplate = eventTemplate;

View File

@@ -1,4 +1,4 @@
using Esiur.Resource.Template;
using Esiur.Data.Types;
using System;
using System.Collections.Generic;
using System.Text;
@@ -9,18 +9,18 @@ namespace Esiur.Resource
public class EventOccurredInfo
{
public readonly EventTemplate EventTemplate;
public readonly EventDef Definition;
public string Name => EventTemplate.Name;
public string Name => Definition.Name;
public readonly IResource Resource;
public readonly object Value;
public EventOccurredInfo(IResource resource, EventTemplate eventTemplate, object value)
public EventOccurredInfo(IResource resource, EventDef eventDef, object value)
{
Resource = resource;
Value = value;
EventTemplate = eventTemplate;
Definition = eventDef;
}
}
}

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
using static Esiur.Resource.Template.PropertyTemplate;
namespace Esiur.Resource;

View File

@@ -24,7 +24,6 @@ SOFTWARE.
using Esiur.Data;
using Esiur.Core;
using Esiur.Resource.Template;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -32,6 +31,7 @@ using System.Text;
using System.Threading.Tasks;
using Esiur.Security.Permissions;
using Esiur.Security.Authority;
using Esiur.Data.Schema;
namespace Esiur.Resource;
public interface IStore : IResource
@@ -73,5 +73,5 @@ public interface IStore : IResource
//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[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
}

View File

@@ -9,13 +9,13 @@ using System.Reflection;
using Esiur.Net.IIP;
using Esiur.Misc;
using Esiur.Security.Permissions;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using Esiur.Proxy;
using Esiur.Core;
using System.Text.Json;
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection.Emit;
using Esiur.Data.Types;
namespace Esiur.Resource;
@@ -29,7 +29,7 @@ public class Instance
WeakReference<IResource> resource;
IStore store;
TypeTemplate template;
TypeDef definition;
AutoList<IPermissionsManager, Instance> managers;
@@ -107,7 +107,7 @@ public class Instance
{
for (var i = 0; i < attributes.Length; i++)
{
var at = template.GetAttributeTemplate(attributes[i]);
var at = definition.GetAttributeDef(attributes[i]);
if (at != null)
{
@@ -128,7 +128,7 @@ public class Instance
{
foreach (var kv in attributes)
{
var at = template.GetAttributeTemplate(kv.Key);
var at = definition.GetAttributeDef(kv.Key);
if (at != null)
if (at.PropertyInfo.CanWrite)
@@ -287,7 +287,7 @@ public class Instance
if (!resource.TryGetTarget(out res))
return false;
var pt = template.GetPropertyTemplateByName(name);
var pt = definition.GetPropertyDefByName(name);
if (pt == null)
return false;
@@ -376,7 +376,7 @@ public class Instance
{
for (byte i = 0; i < properties.Length; i++)
{
var pt = this.template.GetPropertyTemplateByIndex(i);
var pt = this.definition.GetPropertyDefByIndex(i);
if (pt != null)
{
var pv = properties[i];
@@ -413,7 +413,7 @@ public class Instance
var props = new List<PropertyValue>();
foreach (var pt in template.Properties)
foreach (var pt in definition.Properties)
{
var rt = pt.PropertyInfo.GetValue(res, null);
props.Add(new PropertyValue(rt, ages[pt.Index], modificationDates[pt.Index]));
@@ -438,7 +438,7 @@ public class Instance
var props = new Map<byte, PropertyValue>();
foreach (var pt in template.Properties)
foreach (var pt in definition.Properties)
{
if (res.Instance.GetAge(pt.Index) > age)
{
@@ -470,7 +470,7 @@ public class Instance
}
internal void EmitModification(PropertyTemplate pt, object value)
internal void EmitModification(PropertyDef pt, object value)
{
IResource res;
@@ -511,7 +511,7 @@ public class Instance
object value;
if (TryGetPropertyValue(propertyName, out value))
{
var pt = template.GetPropertyTemplateByName(propertyName);
var pt = definition.GetPropertyDefByName(propertyName);
EmitModification(pt, value);
}
}
@@ -520,21 +520,21 @@ public class Instance
// internal void EmitResourceEvent(string name, string[] users, DistributedConnection[] connections, object[] args)
internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, EventTemplate eventTemplate, object value)
internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, EventDef eventDef, object value)
{
IResource res;
if (this.resource.TryGetTarget(out res))
{
CustomEventOccurred?.Invoke(new CustomEventOccurredInfo(res, eventTemplate, receivers, issuer, value));
CustomEventOccurred?.Invoke(new CustomEventOccurredInfo(res, eventDef, receivers, issuer, value));
}
}
internal void EmitResourceEvent(EventTemplate eventTemplate, object value)
internal void EmitResourceEvent(EventDef eventDef, object value)
{
IResource res;
if (this.resource.TryGetTarget(out res))
{
EventOccurred?.Invoke(new EventOccurredInfo(res, eventTemplate, value));
EventOccurred?.Invoke(new EventOccurredInfo(res, eventDef, value));
}
}
@@ -543,8 +543,8 @@ public class Instance
IResource res;
if (this.resource.TryGetTarget(out res))
{
var eventTemplate = template.GetEventTemplateByIndex(eventIndex);
EventOccurred?.Invoke(new EventOccurredInfo(res, eventTemplate, value));
var eventDef = definition.GetEventDefByIndex(eventIndex);
EventOccurred?.Invoke(new EventOccurredInfo(res, eventDef, value));
}
}
@@ -553,8 +553,8 @@ public class Instance
IResource res;
if (this.resource.TryGetTarget(out res))
{
var eventTemplate = template.GetEventTemplateByIndex(eventIndex);
CustomEventOccurred?.Invoke(new CustomEventOccurredInfo(res, eventTemplate, receivers, issuer, value));
var eventDef = definition.GetEventDefByIndex(eventIndex);
CustomEventOccurred?.Invoke(new CustomEventOccurredInfo(res, eventDef, receivers, issuer, value));
}
}
@@ -567,7 +567,7 @@ public class Instance
/// <returns>True, if the resource has the property.</returns>
public bool TryGetPropertyValue(string name, out object value)
{
var pt = template.GetPropertyTemplateByName(name);
var pt = definition.GetPropertyDefByName(name);
IResource res;
if (resource.TryGetTarget(out res))
@@ -680,9 +680,9 @@ public class Instance
/// <summary>
/// Resource template describes the properties, functions and events of the resource.
/// </summary>
public TypeTemplate Template
public TypeDef Definition
{
get { return template; }
get { return definition; }
/*
internal set
@@ -707,7 +707,7 @@ public class Instance
/// <param name="member">Function, property or event to check for permission.</param>
/// <param name="inquirer">Permission inquirer.</param>
/// <returns>Ruling.</returns>
public Ruling Applicable(Session session, ActionType action, MemberTemplate member, object inquirer = null)
public Ruling Applicable(Session session, ActionType action, MemberDef member, object inquirer = null)
{
IResource res;
if (this.resource.TryGetTarget(out res))
@@ -762,15 +762,15 @@ public class Instance
if (resource is IDynamicResource dynamicResource)
{
this.template = dynamicResource.ResourceTemplate;
this.definition = dynamicResource.ResourceDefinition;
}
else
{
this.template = Warehouse.GetTemplateByType(resource.GetType());
this.definition = Warehouse.GetTemplateByType(resource.GetType());
}
// set ages
for (byte i = 0; i < template.Properties.Length; i++)
for (byte i = 0; i < definition.Properties.Length; i++)
{
ages.Add(0);
modificationDates.Add(DateTime.MinValue);
@@ -788,7 +788,7 @@ public class Instance
var emitEventByIndexMethod = GetType().GetMethod("EmitResourceEventByIndex", BindingFlags.Instance | BindingFlags.NonPublic);
var emitCustomEventByIndexMethod = GetType().GetMethod("EmitCustomResourceEventByIndex", BindingFlags.Instance | BindingFlags.NonPublic);
foreach (var evt in template.Events)
foreach (var evt in definition.Events)
{
if (evt.EventInfo == null)

View File

@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using Esiur.Data.Types;
using Esiur.Resource;
using Esiur.Resource.Template;
namespace Esiur.Resource;
public struct PropertyModificationInfo
{
public readonly IResource Resource;
public readonly PropertyTemplate PropertyTemplate;
public readonly PropertyDef PropertyTemplate;
public string Name => PropertyTemplate.Name;
public readonly ulong Age;
public object Value;
public PropertyModificationInfo(IResource resource, PropertyTemplate propertyTemplate, object value, ulong age)
public PropertyModificationInfo(IResource resource, PropertyDef propertyTemplate, object value, ulong age)
{
Resource = resource;
PropertyTemplate = propertyTemplate;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource.Template;
using Esiur.Data.Schema;
namespace Esiur.Resource;
public abstract class Store<T> : IStore where T : IResource
@@ -23,7 +23,7 @@ public abstract class Store<T> : IStore where T : IResource
public abstract AsyncReply<IResource> Get(string path);
public abstract AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
public abstract AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate);
public abstract string Link(IResource resource);

View File

@@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Resource.Template
{
internal class CustomEventOccurredEvent
{
}
}

View File

@@ -24,11 +24,11 @@ SOFTWARE.
using Esiur.Core;
using Esiur.Data;
using Esiur.Data.Types;
using Esiur.Misc;
using Esiur.Net.IIP;
using Esiur.Net.Packets;
using Esiur.Proxy;
using Esiur.Resource.Template;
using Esiur.Security.Permissions;
using System;
using System.Collections;
@@ -36,6 +36,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@@ -58,14 +59,14 @@ public class Warehouse
uint resourceCounter = 0;
KeyList<TemplateType, KeyList<UUID, TypeTemplate>> templates
= new KeyList<TemplateType, KeyList<UUID, TypeTemplate>>()
KeyList<TypeDefKind, KeyList<UUID, TypeDef>> schemas
= new KeyList<TypeDefKind, KeyList<UUID, TypeDef>>()
{
//[TemplateType.Unspecified] = new KeyList<Guid, TypeTemplate>(),
[TemplateType.Resource] = new KeyList<UUID, TypeTemplate>(),
[TemplateType.Record] = new KeyList<UUID, TypeTemplate>(),
//[TemplateType.Wrapper] = new KeyList<Guid, TypeTemplate>(),
[TemplateType.Enum] = new KeyList<UUID, TypeTemplate>(),
//[TemplateType.Unspecified] = new KeyList<Guid, TypeSchema>(),
[TypeDefKind.Resource] = new KeyList<UUID, TypeDef>(),
[TypeDefKind.Record] = new KeyList<UUID, TypeDef>(),
//[TemplateType.Wrapper] = new KeyList<Guid, TypeSchema>(),
[TypeDefKind.Enum] = new KeyList<UUID, TypeDef>(),
};
bool warehouseIsOpen = false;
@@ -87,10 +88,10 @@ public class Warehouse
async (name, attributes)
=> await New<DistributedConnection>(name, null, attributes));
new TypeTemplate(typeof(IIPAuthPacketIAuthHeader), this);
new TypeDef(typeof(IIPAuthPacketIAuthHeader), this);
new TypeTemplate(typeof(IIPAuthPacketIAuthDestination), this);
new TypeTemplate(typeof(IIPAuthPacketIAuthFormat), this);
new TypeDef(typeof(IIPAuthPacketIAuthDestination), this);
new TypeDef(typeof(IIPAuthPacketIAuthFormat), this);
}
@@ -138,19 +139,19 @@ public class Warehouse
var resourceTypes = (Type[])generatedType.GetProperty("Resources").GetValue(null);
foreach (var t in resourceTypes)
{
PutTemplate(new TypeTemplate(t));
RegisterSchema(new TypeDef(t));
}
var recordTypes = (Type[])generatedType.GetProperty("Records").GetValue(null);
foreach (var t in recordTypes)
{
PutTemplate(new TypeTemplate(t));
RegisterSchema(new TypeDef(t));
}
var enumsTypes = (Type[])generatedType.GetProperty("Enums").GetValue(null);
foreach (var t in enumsTypes)
{
PutTemplate(new TypeTemplate(t));
RegisterSchema(new TypeDef(t));
}
}
}
@@ -192,7 +193,7 @@ public class Warehouse
if (!rt)
{
Global.Log("Warehouse", LogType.Warning, $"Resource failed at Initialize {r.Instance.Name} [{r.Instance.Template.ClassName}]");
Global.Log("Warehouse", LogType.Warning, $"Resource failed at Initialize {r.Instance.Name} [{r.Instance.Definition.Name}]");
}
//}
}
@@ -202,7 +203,7 @@ public class Warehouse
var rt = await r.Trigger(ResourceTrigger.SystemInitialized);
if (!rt)
{
Global.Log("Warehouse", LogType.Warning, $"Resource failed at SystemInitialized {r.Instance.Name} [{r.Instance.Template.ClassName}]");
Global.Log("Warehouse", LogType.Warning, $"Resource failed at SystemInitialized {r.Instance.Name} [{r.Instance.Definition.Name}]");
}
}
@@ -345,7 +346,7 @@ public class Warehouse
/// <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, TypeTemplate customTemplate = null, ulong age = 0, IPermissionsManager manager = null, object attributes = null) where T : IResource
//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.");
@@ -526,7 +527,7 @@ public class Warehouse
{
var template = GetTemplateByType(type);
foreach (var kvp in map)
template.GetPropertyTemplateByIndex(kvp.Key).PropertyInfo.SetValue(res, kvp.Value);
template.GetPropertyDefByIndex(kvp.Key).PropertyInfo.SetValue(res, kvp.Value);
}
else
{
@@ -584,15 +585,15 @@ public class Warehouse
}
/// <summary>
/// Put a resource template in the templates warehouse.
/// Put a resource schema in the schemas warehouse.
/// </summary>
/// <param name="template">Resource template.</param>
public void PutTemplate(TypeTemplate template)
/// <param name="schema">Resource schema.</param>
public void RegisterSchema(TypeDef typeDef)
{
if (templates[template.Type].ContainsKey(template.ClassId))
throw new Exception($"Template with same class Id already exists. {templates[template.Type][template.ClassId].ClassName} -> {template.ClassName}");
if (schemas[typeDef.Kind].ContainsKey(typeDef.Id))
throw new Exception($"Template with same class Id already exists. {schemas[typeDef.Kind][typeDef.Id].Name} -> {typeDef.Name}");
templates[template.Type][template.ClassId] = template;
schemas[typeDef.Kind][typeDef.Id] = typeDef;
}
@@ -601,7 +602,7 @@ public class Warehouse
/// </summary>
/// <param name="type">.Net type.</param>
/// <returns>Resource template.</returns>
public TypeTemplate GetTemplateByType(Type type)
public TypeDef GetTemplateByType(Type type)
{
if (!(type.IsClass || type.IsEnum))
return null;
@@ -612,48 +613,48 @@ public class Warehouse
|| baseType == typeof(IRecord))
return null;
TemplateType templateType;
TypeDefKind schemaKind;
if (Codec.ImplementsInterface(type, typeof(IResource)))
templateType = TemplateType.Resource;
schemaKind = TypeDefKind.Resource;
else if (Codec.ImplementsInterface(type, typeof(IRecord)))
templateType = TemplateType.Record;
schemaKind = TypeDefKind.Record;
else if (type.IsEnum)
templateType = TemplateType.Enum;
schemaKind = TypeDefKind.Enum;
else
return null;
var template = templates[templateType].Values.FirstOrDefault(x => x.DefinedType == baseType);
if (template != null)
return template;
var schema = schemas[schemaKind].Values.FirstOrDefault(x => x.DefinedType == baseType);
if (schema != null)
return schema;
// create new template for type
template = new TypeTemplate(baseType, this);
TypeTemplate.GetDependencies(template, this);
schema = new TypeDef(baseType, this);
TypeDef.GetDependencies(schema, this);
return template;
return schema;
}
/// <summary>
/// Get a template by class Id from the templates warehouse. If not in the warehouse, a new ResourceTemplate is created and added to the warehouse.
/// Get a schema by class Id from the templates warehouse. If not in the warehouse, a new ResourceTemplate is created and added to the warehouse.
/// </summary>
/// <param name="classId">Class Id.</param>
/// <returns>Resource template.</returns>
public TypeTemplate GetTemplateByClassId(UUID classId, TemplateType? templateType = null)
public TypeDef GetTypeDefById(UUID typeId, TypeDefKind? templateType = null)
{
if (templateType == null)
{
// look into resources
var template = templates[TemplateType.Resource][classId];
var template = schemas[TypeDefKind.Resource][typeId];
if (template != null)
return template;
// look into records
template = templates[TemplateType.Record][classId];
template = schemas[TypeDefKind.Record][typeId];
if (template != null)
return template;
// look into enums
template = templates[TemplateType.Enum][classId];
template = schemas[TypeDefKind.Enum][typeId];
return template;
//if (template != null)
@@ -663,7 +664,7 @@ public class Warehouse
//return template;
}
else
return templates[templateType.Value][classId];
return schemas[templateType.Value][typeId];
}
@@ -672,22 +673,22 @@ public class Warehouse
/// </summary>
/// <param name="className">Class name.</param>
/// <returns>Resource template.</returns>
public TypeTemplate GetTemplateByClassName(string className, TemplateType? templateType = null)
public TypeDef GetTypeDfByName(string typeName, TypeDefKind? templateType = null)
{
if (templateType == null)
{
// look into resources
var template = templates[TemplateType.Resource].Values.FirstOrDefault(x => x.ClassName == className);
var template = schemas[TypeDefKind.Resource].Values.FirstOrDefault(x => x.Name == typeName);
if (template != null)
return template;
// look into records
template = templates[TemplateType.Record].Values.FirstOrDefault(x => x.ClassName == className);
template = schemas[TypeDefKind.Record].Values.FirstOrDefault(x => x.Name == typeName);
if (template != null)
return template;
// look into enums
template = templates[TemplateType.Enum].Values.FirstOrDefault(x => x.ClassName == className);
template = schemas[TypeDefKind.Enum].Values.FirstOrDefault(x => x.Name == typeName);
//if (template != null)
return template;
@@ -697,7 +698,7 @@ public class Warehouse
}
else
{
return templates[templateType.Value].Values.FirstOrDefault(x => x.ClassName == className);
return schemas[templateType.Value].Values.FirstOrDefault(x => x.Name == typeName);
}
}

View File

@@ -26,13 +26,13 @@ using Esiur.Data;
using Esiur.Core;
using Esiur.Net;
using Esiur.Resource;
using Esiur.Resource.Template;
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Esiur.Data.Types;
namespace Esiur.Security.Permissions;
@@ -47,7 +47,7 @@ public interface IPermissionsManager
/// <param name="member">Function, property or event to check for permission.</param>
/// <param name="inquirer">Permission inquirer object.</param>
/// <returns>Allowed or denined.</returns>
Ruling Applicable(IResource resource, Session session, ActionType action, MemberTemplate member, object inquirer = null);
Ruling Applicable(IResource resource, Session session, ActionType action, MemberDef member, object inquirer = null);
bool Initialize(Map<string, object> settings, IResource resource);

View File

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

View File

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

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource.Template;
using Esiur.Data.Schema;
namespace Esiur.Stores;
@@ -78,7 +78,7 @@ public class MemoryStore : IStore
throw new NotImplementedException();
}
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{
throw new NotImplementedException();
}

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using Esiur.Core;
using Esiur.Data;
using Esiur.Resource.Template;
using Esiur.Data.Schema;
namespace Esiur.Stores;
public class TemporaryStore : IStore
@@ -69,7 +69,7 @@ public class TemporaryStore : IStore
throw new NotImplementedException();
}
public AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
public AsyncReply<KeyList<PropertyDefinition, PropertyValue[]>> GetRecord(IResource resource, DateTime fromDate, DateTime toDate)
{
throw new NotImplementedException();
}