mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-03-31 10:28:21 +00:00
renaming 2
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Net.IIP;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
@@ -52,11 +52,11 @@ namespace Esiur.Proxy
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!TemplateGenerator.urlRegex.IsMatch(path))
|
||||
if (!TypeDefGenerator.urlRegex.IsMatch(path))
|
||||
continue;
|
||||
|
||||
var parts = TemplateGenerator.urlRegex.Split(path);
|
||||
var con = Warehouse.Default.Get<DistributedConnection>($"{parts[1]}://{parts[2]}").Wait(20000);
|
||||
var parts = TypeDefGenerator.urlRegex.Split(path);
|
||||
var con = Warehouse.Default.Get<EpConnection>($"{parts[1]}://{parts[2]}").Wait(20000);
|
||||
var templates = con.GetLinkDefinitions(parts[3]).Wait(60000);
|
||||
|
||||
EmitTemplates(spc, templates);
|
||||
@@ -228,20 +228,20 @@ $@" public partial class {ci.Name} : IResource {{
|
||||
{
|
||||
if (tmp.Kind == TypeDefKind.Resource)
|
||||
{
|
||||
var source = TemplateGenerator.GenerateClass(tmp, templates, false);
|
||||
var source = TypeDefGenerator.GenerateClass(tmp, templates, false);
|
||||
spc.AddSource(tmp.Name + ".g.cs", source);
|
||||
}
|
||||
else if (tmp.Kind == TypeDefKind.Record)
|
||||
{
|
||||
var source = TemplateGenerator.GenerateRecord(tmp, templates);
|
||||
var source = TypeDefGenerator.GenerateRecord(tmp, templates);
|
||||
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.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.ClassName})"))
|
||||
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.Name})"))
|
||||
+ " }; \r\n public static Type[] Records { get; } = new Type[] { " +
|
||||
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.ClassName})"))
|
||||
string.Join(",", templates.Where(x => x.Kind == TypeDefKind.Record).Select(x => $"typeof({x.Name})"))
|
||||
+ " }; " +
|
||||
|
||||
"\r\n } \r\n}";
|
||||
|
||||
@@ -6,13 +6,13 @@ using System.Text;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Esiur.Resource;
|
||||
using Esiur.Net.IIP;
|
||||
using System.Diagnostics;
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Protocol;
|
||||
|
||||
namespace Esiur.Proxy;
|
||||
|
||||
public static class TemplateGenerator
|
||||
public static class TypeDefGenerator
|
||||
{
|
||||
internal static Regex urlRegex = new Regex(@"^(?:([\S]*)://([^/]*)/?)");
|
||||
|
||||
@@ -71,7 +71,7 @@ public static class TemplateGenerator
|
||||
|
||||
var rt = new StringBuilder();
|
||||
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
|
||||
rt.AppendLine($"namespace {nameSpace} {{");
|
||||
|
||||
if (typeDef.Annotations != null)
|
||||
@@ -118,7 +118,7 @@ public static class TemplateGenerator
|
||||
|
||||
var rt = new StringBuilder();
|
||||
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
|
||||
rt.AppendLine($"namespace {nameSpace} {{");
|
||||
|
||||
if (template.Annotations != null)
|
||||
@@ -202,10 +202,10 @@ public static class TemplateGenerator
|
||||
{
|
||||
|
||||
if (!urlRegex.IsMatch(url))
|
||||
throw new Exception("Invalid IIP URL");
|
||||
throw new Exception("Invalid EP URL");
|
||||
|
||||
var path = urlRegex.Split(url);
|
||||
var con = Warehouse.Default.Get<DistributedConnection>(path[1] + "://" + path[2],
|
||||
var con = Warehouse.Default.Get<EpConnection>(path[1] + "://" + path[2],
|
||||
!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) ? new { Username = username, Password = password } : null
|
||||
).Wait(20000);
|
||||
|
||||
@@ -288,7 +288,7 @@ public static class TemplateGenerator
|
||||
|
||||
var rt = new StringBuilder();
|
||||
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
|
||||
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Protocol;");
|
||||
rt.AppendLine("#nullable enable");
|
||||
|
||||
rt.AppendLine($"namespace {nameSpace} {{");
|
||||
@@ -306,12 +306,12 @@ public static class TemplateGenerator
|
||||
|
||||
// extends
|
||||
if (template.ParentId == null)
|
||||
rt.AppendLine($"public class {className} : DistributedResource {{");
|
||||
rt.AppendLine($"public class {className} : EpResource {{");
|
||||
else
|
||||
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) {{}}");
|
||||
rt.AppendLine($"public {className}(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) {{}}");
|
||||
rt.AppendLine($"public {className}() {{}}");
|
||||
|
||||
foreach (var f in template.Functions)
|
||||
@@ -335,7 +335,7 @@ public static class TemplateGenerator
|
||||
if (f.IsStatic)
|
||||
{
|
||||
|
||||
rt.Append($"[Export] public static AsyncReply<{rtTypeName}> {f.Name}(DistributedConnection connection");
|
||||
rt.Append($"[Export] public static AsyncReply<{rtTypeName}> {f.Name}(EpConnection connection");
|
||||
|
||||
if (positionalArgs.Length > 0)
|
||||
rt.Append(", " +
|
||||
Reference in New Issue
Block a user