mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 19:42:58 +00:00
Custom names
This commit is contained in:
parent
a25e5a71f2
commit
1166e93ba9
@ -9,7 +9,7 @@
|
|||||||
<Product>Esiur Entity Framework Extension</Product>
|
<Product>Esiur Entity Framework Extension</Product>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<PackageId>Esiur.Stores.EntityCore</PackageId>
|
<PackageId>Esiur.Stores.EntityCore</PackageId>
|
||||||
<Version>1.2.3</Version>
|
<Version>1.2.5</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -155,8 +155,9 @@ namespace Esiur.Stores.EntityCore
|
|||||||
|
|
||||||
if (extension == null)
|
if (extension == null)
|
||||||
{
|
{
|
||||||
|
if (store == null)
|
||||||
|
return optionsBuilder;
|
||||||
|
|
||||||
//var store = Warehouse.New<EntityStore>(name, null, parent, manager, new { Options = optionsBuilder, DbContextProvider = dbContextProvider }).Wait();
|
|
||||||
store.Options = optionsBuilder.Options;
|
store.Options = optionsBuilder.Options;
|
||||||
extension = new EsiurExtensionOptions(store);
|
extension = new EsiurExtensionOptions(store);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ namespace Esiur.Data
|
|||||||
|
|
||||||
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
|
var template = Warehouse.GetTemplateByClassId(classId, TemplateType.Record);
|
||||||
|
|
||||||
reply.ArrayType = template.DefinedType;
|
reply.ArrayType = template?.DefinedType;
|
||||||
|
|
||||||
AsyncReply<IRecord> previous = null;
|
AsyncReply<IRecord> previous = null;
|
||||||
|
|
||||||
@ -936,6 +936,10 @@ namespace Esiur.Data
|
|||||||
if (resources == null || resources?.Length == 0)
|
if (resources == null || resources?.Length == 0)
|
||||||
return prependLength ? new byte[] { 0, 0, 0, 0 } : new byte[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 rt = new BinaryList();
|
||||||
var comparsion = Compare(null, resources[0], connection);
|
var comparsion = Compare(null, resources[0], connection);
|
||||||
|
|
||||||
@ -1355,6 +1359,7 @@ namespace Esiur.Data
|
|||||||
|
|
||||||
case DataType.DistributedResource:
|
case DataType.DistributedResource:
|
||||||
//rt.Append((value as IResource).Instance.Template.ClassId, (value as IResource).Instance.Id);
|
//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);
|
rt.AddUInt32((value as IResource).Instance.Id);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
|
<PackageLicenseUrl>https://github.com/Esiur/Esiur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
|
||||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>1.8.6.1</Version>
|
<Version>1.8.8</Version>
|
||||||
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
|
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
|
||||||
<Authors>Ahmed Kh. Zamil</Authors>
|
<Authors>Ahmed Kh. Zamil</Authors>
|
||||||
<AssemblyVersion>1.8.6.1</AssemblyVersion>
|
<AssemblyVersion>1.8.8.0</AssemblyVersion>
|
||||||
<Company>Esiur Foundation</Company>
|
<Company>Esiur Foundation</Company>
|
||||||
<FileVersion>1.8.6.1</FileVersion>
|
<FileVersion>1.8.8.0</FileVersion>
|
||||||
<AssemblyName>Esiur</AssemblyName>
|
<AssemblyName>Esiur</AssemblyName>
|
||||||
<RootNamespace>Esiur</RootNamespace>
|
<RootNamespace>Esiur</RootNamespace>
|
||||||
<PackageId>Esiur</PackageId>
|
<PackageId>Esiur</PackageId>
|
||||||
|
@ -57,7 +57,7 @@ namespace Esiur.Net.HTTP
|
|||||||
return new AsyncReply<bool>(false);
|
return new AsyncReply<bool>(false);
|
||||||
|
|
||||||
var httpServer = sender.Parent;
|
var httpServer = sender.Parent;
|
||||||
var wsSocket = new WSSocket(tcpSocket);
|
var wsSocket = new WSocket(tcpSocket);
|
||||||
httpServer.Remove(sender);
|
httpServer.Remove(sender);
|
||||||
|
|
||||||
var iipConnection = new DistributedConnection();
|
var iipConnection = new DistributedConnection();
|
||||||
|
@ -58,6 +58,9 @@ namespace Esiur.Net.IIP
|
|||||||
//List<IResource> subscriptions = new List<IResource>();
|
//List<IResource> subscriptions = new List<IResource>();
|
||||||
Dictionary<IResource, List<byte>> subscriptions = new Dictionary<IResource, List<byte>>();// new List<IResource>();
|
Dictionary<IResource, List<byte>> subscriptions = new Dictionary<IResource, List<byte>>();// new List<IResource>();
|
||||||
|
|
||||||
|
|
||||||
|
internal KeyList<IResource, DateTime> cache = new();
|
||||||
|
|
||||||
object subscriptionsLock = new object();
|
object subscriptionsLock = new object();
|
||||||
|
|
||||||
AsyncQueue<DistributedResourceQueueItem> queue = new AsyncQueue<DistributedResourceQueueItem>();
|
AsyncQueue<DistributedResourceQueueItem> queue = new AsyncQueue<DistributedResourceQueueItem>();
|
||||||
|
@ -38,7 +38,7 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Esiur.Net.Sockets
|
namespace Esiur.Net.Sockets
|
||||||
{
|
{
|
||||||
public class WSSocket : ISocket, INetworkReceiver<ISocket>
|
public class WSocket : ISocket, INetworkReceiver<ISocket>
|
||||||
{
|
{
|
||||||
WebsocketPacket pkt_receive = new WebsocketPacket();
|
WebsocketPacket pkt_receive = new WebsocketPacket();
|
||||||
WebsocketPacket pkt_send = new WebsocketPacket();
|
WebsocketPacket pkt_send = new WebsocketPacket();
|
||||||
@ -80,7 +80,7 @@ namespace Esiur.Net.Sockets
|
|||||||
|
|
||||||
public INetworkReceiver<ISocket> Receiver { get; set; }
|
public INetworkReceiver<ISocket> Receiver { get; set; }
|
||||||
|
|
||||||
public WSSocket(ISocket socket)
|
public WSocket(ISocket socket)
|
||||||
{
|
{
|
||||||
pkt_send.FIN = true;
|
pkt_send.FIN = true;
|
||||||
pkt_send.Mask = false;
|
pkt_send.Mask = false;
|
@ -20,8 +20,6 @@ namespace Esiur.Proxy
|
|||||||
public class ResourceGenerator : ISourceGenerator
|
public class ResourceGenerator : ISourceGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private KeyList<string, TypeTemplate[]> cache = new();
|
private KeyList<string, TypeTemplate[]> cache = new();
|
||||||
// private List<string> inProgress = new();
|
// private List<string> inProgress = new();
|
||||||
|
|
||||||
@ -39,8 +37,6 @@ namespace Esiur.Proxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GenerateModel(GeneratorExecutionContext context, TypeTemplate[] templates)
|
void GenerateModel(GeneratorExecutionContext context, TypeTemplate[] templates)
|
||||||
{
|
{
|
||||||
foreach (var tmp in templates)
|
foreach (var tmp in templates)
|
||||||
@ -163,10 +159,16 @@ public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
|
|||||||
code += "public AsyncReply<bool> Trigger(ResourceTrigger trigger) => new AsyncReply<bool>(true);\r\n";
|
code += "public AsyncReply<bool> Trigger(ResourceTrigger trigger) => new AsyncReply<bool>(true);\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Debugger.Launch();
|
||||||
|
|
||||||
foreach (var f in ci.Fields)
|
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 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
|
// copy attributes
|
||||||
var attrs = string.Join(" ", f.GetAttributes().Select(x => $"[{x.ToString()}]"));
|
var attrs = string.Join(" ", f.GetAttributes().Select(x => $"[{x.ToString()}]"));
|
||||||
|
@ -33,10 +33,10 @@ namespace Esiur.Resource
|
|||||||
[AttributeUsage(AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
public class AttributeAttribute : System.Attribute
|
public class AttributeAttribute : System.Attribute
|
||||||
{
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
public AttributeAttribute()
|
public AttributeAttribute(string name = null)
|
||||||
{
|
{
|
||||||
|
this.Name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,11 @@ namespace Esiur.Resource
|
|||||||
|
|
||||||
public class PublicAttribute : Attribute
|
public class PublicAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
// public StorageMode Storage { get; set; }
|
public PublicAttribute(string name = null)
|
||||||
|
|
||||||
//public bool Serialize { get; set; }
|
|
||||||
|
|
||||||
public PublicAttribute()//StorageMode storage = StorageMode.NonVolatile, bool serialize = true)
|
|
||||||
{
|
{
|
||||||
// Storage = storage;
|
Name = name;
|
||||||
//Serialize = serialize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,18 @@ namespace Esiur.Resource.Template
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MemberTemplate GetMemberTemplate(MemberInfo member)
|
|
||||||
{
|
//public MemberTemplate GetMemberTemplate(MemberInfo member)
|
||||||
if (member is MethodInfo)
|
//{
|
||||||
return GetFunctionTemplateByName(member.Name);
|
// if (member is MethodInfo)
|
||||||
else if (member is EventInfo)
|
// return GetFunctionTemplateByName(member.Name);
|
||||||
return GetEventTemplateByName(member.Name);
|
// else if (member is EventInfo)
|
||||||
else if (member is PropertyInfo)
|
// return GetEventTemplateByName(member.Name);
|
||||||
return GetPropertyTemplateByName(member.Name);
|
// else if (member is PropertyInfo)
|
||||||
else
|
// return GetPropertyTemplateByName(member.Name);
|
||||||
return null;
|
// else
|
||||||
}
|
// return null;
|
||||||
|
//}
|
||||||
|
|
||||||
public EventTemplate GetEventTemplateByName(string eventName)
|
public EventTemplate GetEventTemplateByName(string eventName)
|
||||||
{
|
{
|
||||||
@ -344,7 +345,8 @@ namespace Esiur.Resource.Template
|
|||||||
var attributeAttr = pi.GetCustomAttribute<AttributeAttribute>(true);
|
var attributeAttr = pi.GetCustomAttribute<AttributeAttribute>(true);
|
||||||
if (attributeAttr != null)
|
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;
|
at.PropertyInfo = pi;
|
||||||
attributes.Add(at);
|
attributes.Add(at);
|
||||||
}
|
}
|
||||||
@ -427,8 +429,9 @@ namespace Esiur.Resource.Template
|
|||||||
var annotationAttr = pi.GetCustomAttribute<AnnotationAttribute>(true);
|
var annotationAttr = pi.GetCustomAttribute<AnnotationAttribute>(true);
|
||||||
var storageAttr = pi.GetCustomAttribute<StorageAttribute>(true);
|
var storageAttr = pi.GetCustomAttribute<StorageAttribute>(true);
|
||||||
var valueType = TemplateDataType.FromType(pi.PropertyType);
|
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)
|
if (storageAttr != null)
|
||||||
pt.Recordable = storageAttr.Mode == StorageMode.Recordable;
|
pt.Recordable = storageAttr.Mode == StorageMode.Recordable;
|
||||||
|
|
||||||
@ -446,7 +449,8 @@ namespace Esiur.Resource.Template
|
|||||||
var attributeAttr = pi.GetCustomAttribute<AttributeAttribute>(true);
|
var attributeAttr = pi.GetCustomAttribute<AttributeAttribute>(true);
|
||||||
if (attributeAttr != null)
|
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;
|
at.PropertyInfo = pi;
|
||||||
attributes.Add(at);
|
attributes.Add(at);
|
||||||
}
|
}
|
||||||
@ -467,7 +471,9 @@ namespace Esiur.Resource.Template
|
|||||||
|
|
||||||
var argType = ei.EventHandlerType.GenericTypeArguments[0];
|
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;
|
et.EventInfo = ei;
|
||||||
|
|
||||||
if (annotationAttr != null)
|
if (annotationAttr != null)
|
||||||
@ -505,7 +511,9 @@ namespace Esiur.Resource.Template
|
|||||||
})
|
})
|
||||||
.ToArray();
|
.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)
|
if (annotationAttr != null)
|
||||||
ft.Expansion = annotationAttr.Annotation;
|
ft.Expansion = annotationAttr.Annotation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user