diff --git a/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj b/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj index f799cc0..3640eee 100644 --- a/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj +++ b/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj @@ -9,7 +9,7 @@ Esiur Entity Framework Extension true Esiur.Stores.EntityCore - 1.2.3 + 1.2.5 diff --git a/Esiur.Stores.EntityCore/EsiurExtensions.cs b/Esiur.Stores.EntityCore/EsiurExtensions.cs index 751ebe6..a9a99e0 100644 --- a/Esiur.Stores.EntityCore/EsiurExtensions.cs +++ b/Esiur.Stores.EntityCore/EsiurExtensions.cs @@ -79,7 +79,7 @@ namespace Esiur.Stores.EntityCore foreach (var p in ps) { - + var mi = resType.GetMember(p.Key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) .FirstOrDefault(); @@ -155,8 +155,9 @@ namespace Esiur.Stores.EntityCore if (extension == null) { + if (store == null) + return optionsBuilder; - //var store = Warehouse.New(name, null, parent, manager, new { Options = optionsBuilder, DbContextProvider = dbContextProvider }).Wait(); store.Options = optionsBuilder.Options; extension = new EsiurExtensionOptions(store); } diff --git a/Esiur/Data/Codec.cs b/Esiur/Data/Codec.cs index c2c9182..14a271e 100644 --- a/Esiur/Data/Codec.cs +++ b/Esiur/Data/Codec.cs @@ -278,7 +278,7 @@ namespace Esiur.Data var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record); - reply.ArrayType = template.DefinedType; + reply.ArrayType = template?.DefinedType; AsyncReply previous = null; @@ -936,6 +936,10 @@ namespace Esiur.Data if (resources == null || resources?.Length == 0) return prependLength ? new byte[] { 0, 0, 0, 0 } : new byte[0]; + + foreach(var r in resources) + connection.cache.Add(r, DateTime.UtcNow); + var rt = new BinaryList(); var comparsion = Compare(null, resources[0], connection); @@ -1355,6 +1359,7 @@ namespace Esiur.Data case DataType.DistributedResource: //rt.Append((value as IResource).Instance.Template.ClassId, (value as IResource).Instance.Id); + connection.cache.Add(value as IResource, DateTime.UtcNow); rt.AddUInt32((value as IResource).Instance.Id); break; diff --git a/Esiur/Esiur.csproj b/Esiur/Esiur.csproj index 471923b..f3223ef 100644 --- a/Esiur/Esiur.csproj +++ b/Esiur/Esiur.csproj @@ -7,12 +7,12 @@ https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE http://www.esiur.com true - 1.8.6.1 + 1.8.8 https://github.com/esiur/esiur-dotnet Ahmed Kh. Zamil - 1.8.6.1 + 1.8.8.0 Esiur Foundation - 1.8.6.1 + 1.8.8.0 Esiur Esiur Esiur diff --git a/Esiur/Net/HTTP/IIPoWS.cs b/Esiur/Net/HTTP/IIPoWS.cs index 4418be3..60dba37 100644 --- a/Esiur/Net/HTTP/IIPoWS.cs +++ b/Esiur/Net/HTTP/IIPoWS.cs @@ -57,7 +57,7 @@ namespace Esiur.Net.HTTP return new AsyncReply(false); var httpServer = sender.Parent; - var wsSocket = new WSSocket(tcpSocket); + var wsSocket = new WSocket(tcpSocket); httpServer.Remove(sender); var iipConnection = new DistributedConnection(); diff --git a/Esiur/Net/IIP/DistributedConnectionProtocol.cs b/Esiur/Net/IIP/DistributedConnectionProtocol.cs index 4650e65..a9215e8 100644 --- a/Esiur/Net/IIP/DistributedConnectionProtocol.cs +++ b/Esiur/Net/IIP/DistributedConnectionProtocol.cs @@ -58,6 +58,9 @@ namespace Esiur.Net.IIP //List subscriptions = new List(); Dictionary> subscriptions = new Dictionary>();// new List(); + + internal KeyList cache = new(); + object subscriptionsLock = new object(); AsyncQueue queue = new AsyncQueue(); diff --git a/Esiur/Net/Sockets/WSSocket.cs b/Esiur/Net/Sockets/WSocket.cs similarity index 99% rename from Esiur/Net/Sockets/WSSocket.cs rename to Esiur/Net/Sockets/WSocket.cs index dd122a1..6fbfcba 100644 --- a/Esiur/Net/Sockets/WSSocket.cs +++ b/Esiur/Net/Sockets/WSocket.cs @@ -38,7 +38,7 @@ using System.Globalization; namespace Esiur.Net.Sockets { - public class WSSocket : ISocket, INetworkReceiver + public class WSocket : ISocket, INetworkReceiver { WebsocketPacket pkt_receive = new WebsocketPacket(); WebsocketPacket pkt_send = new WebsocketPacket(); @@ -80,7 +80,7 @@ namespace Esiur.Net.Sockets public INetworkReceiver Receiver { get; set; } - public WSSocket(ISocket socket) + public WSocket(ISocket socket) { pkt_send.FIN = true; pkt_send.Mask = false; diff --git a/Esiur/Proxy/ResourceGenerator.cs b/Esiur/Proxy/ResourceGenerator.cs index 708ab69..ed41035 100644 --- a/Esiur/Proxy/ResourceGenerator.cs +++ b/Esiur/Proxy/ResourceGenerator.cs @@ -20,8 +20,6 @@ namespace Esiur.Proxy public class ResourceGenerator : ISourceGenerator { - - private KeyList cache = new(); // private List inProgress = new(); @@ -38,9 +36,7 @@ namespace Esiur.Proxy context.ReportDiagnostic(Diagnostic.Create(new DiagnosticDescriptor("MySG001", title, msg, category, DiagnosticSeverity.Error, true), Location.None)); } - - - + void GenerateModel(GeneratorExecutionContext context, TypeTemplate[] templates) { foreach (var tmp in templates) @@ -163,10 +159,16 @@ public virtual void Destroy() {{ OnDestroy?.Invoke(this); }} code += "public AsyncReply Trigger(ResourceTrigger trigger) => new AsyncReply(true);\r\n"; } + //Debugger.Launch(); + foreach (var f in ci.Fields) { + var givenName = f.GetAttributes().Where(x=>x.AttributeClass.Name == "PublicAttribute").FirstOrDefault()?.ConstructorArguments.FirstOrDefault().Value; + var fn = f.Name; - var pn = fn.Substring(0, 1).ToUpper() + fn.Substring(1); + var pn = givenName ?? fn.Substring(0, 1).ToUpper() + fn.Substring(1); + + //System.IO.File.AppendAllText("c:\\gen\\fields.txt", fn + " -> " + pn + "\r\n"); // copy attributes var attrs = string.Join(" ", f.GetAttributes().Select(x => $"[{x.ToString()}]")); diff --git a/Esiur/Resource/AttributeAttribute.cs b/Esiur/Resource/AttributeAttribute.cs index aa0b393..0e78663 100644 --- a/Esiur/Resource/AttributeAttribute.cs +++ b/Esiur/Resource/AttributeAttribute.cs @@ -33,10 +33,10 @@ namespace Esiur.Resource [AttributeUsage(AttributeTargets.Property)] public class AttributeAttribute : System.Attribute { - - public AttributeAttribute() + public string Name { get; set; } + public AttributeAttribute(string name = null) { - + this.Name = name; } } } diff --git a/Esiur/Resource/PublicAttribute.cs b/Esiur/Resource/PublicAttribute.cs index 35c3c20..9f70f9b 100644 --- a/Esiur/Resource/PublicAttribute.cs +++ b/Esiur/Resource/PublicAttribute.cs @@ -8,15 +8,11 @@ namespace Esiur.Resource public class PublicAttribute : Attribute { + public string Name { get; set; } - // public StorageMode Storage { get; set; } - - //public bool Serialize { get; set; } - - public PublicAttribute()//StorageMode storage = StorageMode.NonVolatile, bool serialize = true) + public PublicAttribute(string name = null) { - // Storage = storage; - //Serialize = serialize; + Name = name; } } } diff --git a/Esiur/Resource/Template/TypeTemplate.cs b/Esiur/Resource/Template/TypeTemplate.cs index 7a87aee..a9c5eed 100644 --- a/Esiur/Resource/Template/TypeTemplate.cs +++ b/Esiur/Resource/Template/TypeTemplate.cs @@ -48,17 +48,18 @@ namespace Esiur.Resource.Template - public MemberTemplate GetMemberTemplate(MemberInfo member) - { - if (member is MethodInfo) - return GetFunctionTemplateByName(member.Name); - else if (member is EventInfo) - return GetEventTemplateByName(member.Name); - else if (member is PropertyInfo) - return GetPropertyTemplateByName(member.Name); - else - return null; - } + + //public MemberTemplate GetMemberTemplate(MemberInfo member) + //{ + // if (member is MethodInfo) + // return GetFunctionTemplateByName(member.Name); + // else if (member is EventInfo) + // return GetEventTemplateByName(member.Name); + // else if (member is PropertyInfo) + // return GetPropertyTemplateByName(member.Name); + // else + // return null; + //} public EventTemplate GetEventTemplateByName(string eventName) { @@ -344,7 +345,8 @@ namespace Esiur.Resource.Template var attributeAttr = pi.GetCustomAttribute(true); if (attributeAttr != null) { - var at = new AttributeTemplate(this, 0, pi.Name); + var an = attributeAttr.Name ?? pi.Name; + var at = new AttributeTemplate(this, 0, an); at.PropertyInfo = pi; attributes.Add(at); } @@ -427,8 +429,9 @@ namespace Esiur.Resource.Template var annotationAttr = pi.GetCustomAttribute(true); var storageAttr = pi.GetCustomAttribute(true); var valueType = TemplateDataType.FromType(pi.PropertyType); + var pn = publicAttr.Name ?? pi.Name; - var pt = new PropertyTemplate(this, i++, pi.Name, valueType);//, rp.ReadExpansion, rp.WriteExpansion, rp.Storage); + var pt = new PropertyTemplate(this, i++, pn, valueType);//, rp.ReadExpansion, rp.WriteExpansion, rp.Storage); if (storageAttr != null) pt.Recordable = storageAttr.Mode == StorageMode.Recordable; @@ -446,7 +449,8 @@ namespace Esiur.Resource.Template var attributeAttr = pi.GetCustomAttribute(true); if (attributeAttr != null) { - var at = new AttributeTemplate(this, 0, pi.Name); + var pn = attributeAttr.Name ?? pi.Name; + var at = new AttributeTemplate(this, 0, pn); at.PropertyInfo = pi; attributes.Add(at); } @@ -467,7 +471,9 @@ namespace Esiur.Resource.Template var argType = ei.EventHandlerType.GenericTypeArguments[0]; - var et = new EventTemplate(this, i++, ei.Name, TemplateDataType.FromType(argType)); + var en = publicAttr.Name ?? ei.Name; + + var et = new EventTemplate(this, i++, en, TemplateDataType.FromType(argType)); et.EventInfo = ei; if (annotationAttr != null) @@ -505,7 +511,9 @@ namespace Esiur.Resource.Template }) .ToArray(); - var ft = new FunctionTemplate(this, i++, mi.Name, arguments, returnType);// mi.ReturnType == typeof(void)); + var fn = publicAttr.Name ?? mi.Name; + + var ft = new FunctionTemplate(this, i++, fn, arguments, returnType);// mi.ReturnType == typeof(void)); if (annotationAttr != null) ft.Expansion = annotationAttr.Annotation;