2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

fix generator

This commit is contained in:
2022-06-16 03:02:14 +03:00
parent 80922a13ee
commit f5e61d4b86
14 changed files with 159 additions and 80 deletions

View File

@ -46,6 +46,8 @@ partial class DistributedConnection
KeyList<uint, AsyncReply<DistributedResource>> resourceRequests = new KeyList<uint, AsyncReply<DistributedResource>>();
KeyList<Guid, AsyncReply<TypeTemplate>> templateRequests = new KeyList<Guid, AsyncReply<TypeTemplate>>();
KeyList<string, AsyncReply<TypeTemplate>> templateByNameRequests = new KeyList<string, AsyncReply<TypeTemplate>>();
KeyList<string, AsyncReply<IResource>> pathRequests = new KeyList<string, AsyncReply<IResource>>();
@ -1888,6 +1890,39 @@ partial class DistributedConnection
return reply;
}
public AsyncReply<TypeTemplate> GetTemplateByClassName(string className)
{
var template = templates.Values.FirstOrDefault(x => x.ClassName == className);
if (template != null)
return new AsyncReply<TypeTemplate>(template);
if (templateByNameRequests.ContainsKey(className))
return templateByNameRequests[className];
var reply = new AsyncReply<TypeTemplate>();
templateByNameRequests.Add(className, reply);
var classNameBytes = DC.ToBytes(className);
SendRequest(IIPPacket.IIPPacketAction.TemplateFromClassName)
.AddUInt8((byte)classNameBytes.Length)
.AddUInt8Array(classNameBytes)
.Done()
.Then((rt) =>
{
templateByNameRequests.Remove(className);
templates.Add(((TypeTemplate)rt[0]).ClassId, (TypeTemplate)rt[0]);
Warehouse.PutTemplate(rt[0] as TypeTemplate);
reply.Trigger(rt[0]);
}).Error((ex) =>
{
reply.TriggerError(ex);
});
return reply;
}
// IStore interface
/// <summary>
/// Get a resource by its path.

View File

@ -222,6 +222,7 @@ public class DistributedResource : DynamicObject, IResource
public AsyncReply<object> _Invoke(byte index, Map<byte, object> args)
{
if (destroyed)
throw new Exception("Trying to access destroyed object");