2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 14:38:43 +00:00
This commit is contained in:
2026-05-26 16:18:57 +03:00
parent e4a54ffbe8
commit a91fc7d262
29 changed files with 206 additions and 148 deletions
+11 -9
View File
@@ -111,9 +111,9 @@ namespace Esiur.Proxy
code.AppendLine("public virtual event DestroyedEvent? OnDestroy;");
code.AppendLine("public virtual void Destroy() { OnDestroy?.Invoke(this); }");
if (!ci.HasTrigger)
if (!ci.HasHandle)
{
code.AppendLine("public virtual AsyncReply<bool> Trigger(ResourceTrigger trigger) => new AsyncReply<bool>(true);");
code.AppendLine("public virtual AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null) => new AsyncReply<bool>(true);");
}
}
@@ -181,11 +181,13 @@ namespace Esiur.Proxy
ResourceClassInfo? classInfo = null;
if (hasResource)
{
bool hasTrigger = cds.Members
bool hasHandle = cds.Members
.OfType<MethodDeclarationSyntax>()
.Select(m => ctx.SemanticModel.GetDeclaredSymbol(m) as IMethodSymbol)
.Where(s => s is not null)
.Any(s => s!.Name == "Trigger" && s.Parameters.Length == 1 && s.Parameters[0].Type.ToDisplayString() == "Esiur.Resource.ResourceTrigger");
.Any(s => s!.Name == "Handle" && s.Parameters.Length == 2
&& s.Parameters[0].Type.ToDisplayString() == "Esiur.Resource.ResourceOperation"
&& s.Parameters[1].Type.ToDisplayString() == "Esiur.Resource.IResourceContext");
var exportedFields = cds.Members
.OfType<FieldDeclarationSyntax>()
@@ -208,7 +210,7 @@ namespace Esiur.Proxy
cls,
exportedFields,
hasInterface,
hasTrigger
hasHandle
);
}
@@ -228,7 +230,7 @@ namespace Esiur.Proxy
{
Fields = mergedFields,
HasInterface = existing.HasInterface || item.HasInterface,
HasTrigger = existing.HasTrigger || item.HasTrigger
HasHandle = existing.HasHandle || item.HasHandle
};
}
else
@@ -337,7 +339,7 @@ namespace Esiur.Proxy
public ResourceClassInfo(string key, string name ,
ClassDeclarationSyntax classDeclaration,
ITypeSymbol classSymbol, List<IFieldSymbol> fileds, bool hasInterface, bool hasTrigger)
ITypeSymbol classSymbol, List<IFieldSymbol> fileds, bool hasInterface, bool hasHandle)
{
Key = key;
Name = name;
@@ -345,7 +347,7 @@ namespace Esiur.Proxy
ClassSymbol = classSymbol;
Fields = fileds;
HasInterface = hasInterface;
HasTrigger = hasTrigger;
HasHandle = hasHandle;
}
public string Key;
@@ -354,7 +356,7 @@ namespace Esiur.Proxy
public ITypeSymbol ClassSymbol;
public List<IFieldSymbol> Fields;
public bool HasInterface;
public bool HasTrigger;
public bool HasHandle;
}
}
}
+8 -4
View File
@@ -218,10 +218,14 @@ public static class TypeDefGenerator
throw new Exception("Invalid EP URL");
var path = urlRegex.Split(url);
var con = Warehouse.Default.Get<EpConnection>(path[1] + "://" + path[2], new ResourceContext(0,
new Map<string, object> { ["username"] = username, ["password"] = password }, null, null)
// !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null
).Wait(20000);
var con = Warehouse.Default.Get<EpConnection>(path[1] + "://" + path[2], new EpConnectionContext()
{
Identity = username
}).Wait(10000);
//ResourceContext(0,
// new Map<string, object> { ["username"] = username, ["password"] = password }, null, null)
// ).Wait(20000);
if (con == null)
throw new Exception("Can't connect to server");