diff --git a/Libraries/Esiur/Data/Types/RemoteTypeDef.cs b/Libraries/Esiur/Data/Types/RemoteTypeDef.cs index 6a00110..b6e5c43 100644 --- a/Libraries/Esiur/Data/Types/RemoteTypeDef.cs +++ b/Libraries/Esiur/Data/Types/RemoteTypeDef.cs @@ -124,6 +124,9 @@ public class RemoteTypeDef:TypeDef } } + // try to get proxy type + od._proxyType = connection.Instance?.Warehouse?.TryGetProxyType(od.Kind, od.Domain, od.Name); + return od; } } diff --git a/Libraries/Esiur/Protocol/EpConnection.cs b/Libraries/Esiur/Protocol/EpConnection.cs index b6d5300..9dfbcbe 100644 --- a/Libraries/Esiur/Protocol/EpConnection.cs +++ b/Libraries/Esiur/Protocol/EpConnection.cs @@ -736,7 +736,7 @@ public partial class EpConnection : NetworkConnection, IStore } SendAuthHeaders(EpAuthPacketMethod.SessionEstablished, localHeaders); - + _session.Authenticated = true; _session.LocalIdentity = null; _session.RemoteIdentity = null; diff --git a/Libraries/Esiur/Proxy/TypeDefGenerator.cs b/Libraries/Esiur/Proxy/TypeDefGenerator.cs index 4be5c8a..8f020b8 100644 --- a/Libraries/Esiur/Proxy/TypeDefGenerator.cs +++ b/Libraries/Esiur/Proxy/TypeDefGenerator.cs @@ -271,9 +271,13 @@ public static class TypeDefGenerator // generate info class + var mainClassName = typeDefs.FirstOrDefault().Name?.Split('.'); + + var mainNamespace = mainClassName != null ? string.Join(".", mainClassName.Take(mainClassName.Length - 1)) : "Esiur"; + var typesFile = @"using System; - namespace Esiur { - public static class Generated { + namespace " + mainNamespace + @" { + public static class Initialization { public static Type[] Resources {get;} = new Type[] { " + string.Join(",", typeDefs.Where(x => x.Kind == TypeDefKind.Resource).Select(x => $"typeof({x.Name})")) + @" }; @@ -282,11 +286,22 @@ public static class TypeDefGenerator + @" }; public static Type[] Enums { get; } = new Type[] { " + string.Join(",", typeDefs.Where(x => x.Kind == TypeDefKind.Enum).Select(x => $"typeof({x.Name})")) - + @" };" + - "\r\n } \r\n}"; + + @" }; + public static void RegisterTypes(Warehouse warehouse) + { + foreach(var type in Resources) + warehouse.RegisterProxyType(type); + + foreach(var type in Records) + warehouse.RegisterProxyType(type); + + foreach(var type in Enums) + warehouse.RegisterProxyType(type); + } + \r\n } \r\n}"; - File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + "Esiur.g.cs", typesFile); + File.WriteAllText(dstDir.FullName + Path.DirectorySeparatorChar + "Initialization.g.cs", typesFile); return dstDir.FullName; diff --git a/Libraries/Esiur/Resource/RemoteAttribute.cs b/Libraries/Esiur/Resource/RemoteAttribute.cs index 595a18b..88d3b5b 100644 --- a/Libraries/Esiur/Resource/RemoteAttribute.cs +++ b/Libraries/Esiur/Resource/RemoteAttribute.cs @@ -1,19 +1,203 @@ using System; using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Net.Sockets; using System.Text; +using System.Text.RegularExpressions; namespace Esiur.Resource { [AttributeUsage(AttributeTargets.Enum | AttributeTargets.Class, Inherited = false)] - public class RemoteAttribute:Attribute + public class RemoteAttribute : Attribute { - public string Domain { get; private set; } + public string[] Domains { get; private set; } public string FullName { get; private set; } - public RemoteAttribute(string domain, string fullName) + static readonly Regex StrictIPv4 = new( +@"^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$", +RegexOptions.Compiled | RegexOptions.CultureInvariant); + + static readonly Regex IPv4Like = new( + @"^\d+(?:\.\d+){3}$", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + static readonly Regex HostName = new( + @"^(?=.{1,253}\.?$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)*[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.?$", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + + public bool IsValidFullName() { - Domain = domain; + return IsValidQualifiedClassName(FullName, true, false); ; + } + + private static readonly HashSet ReservedKeywords = new HashSet( + new[] + { + "abstract", "as", "base", "bool", "break", "byte", "case", "catch", + "char", "checked", "class", "const", "continue", "decimal", "default", + "delegate", "do", "double", "else", "enum", "event", "explicit", + "extern", "false", "finally", "fixed", "float", "for", "foreach", + "goto", "if", "implicit", "in", "int", "interface", "internal", + "is", "lock", "long", "namespace", "new", "null", "object", + "operator", "out", "override", "params", "private", "protected", + "public", "readonly", "ref", "return", "sbyte", "sealed", "short", + "sizeof", "stackalloc", "static", "string", "struct", "switch", + "this", "throw", "true", "try", "typeof", "uint", "ulong", + "unchecked", "unsafe", "ushort", "using", "virtual", "void", + "volatile", "while" + }, + StringComparer.Ordinal); + + public RemoteAttribute(string fullName, params string[] domains) + { + Domains = domains; FullName = fullName; } + + // @TODO: support wildcard records + public bool AreValidDomains() + { + foreach(var domain in Domains) + { + if (!IsValidDomain(domain)) + return false; + } + + return true; + } + + private bool IsValidDomain(string domain) + { + if (string.IsNullOrWhiteSpace(domain)) + return false; + + string s = domain.Trim(); + + // Accept URI-style IPv6 literals, e.g. [::1] + if (s.Length > 2 && s[0] == '[' && s[s.Length - 1] == ']') + s = s.Substring(1, s.Length - 2); + + // Strict IPv4 only: 0.0.0.0 to 255.255.255.255 + if (StrictIPv4.IsMatch(s)) + return true; + + // Reject IPv4-looking strings that failed strict IPv4, + // e.g. 999.999.999.999 + if (IPv4Like.IsMatch(s)) + return false; + + IPAddress ip; + + // IPv6 + if (IPAddress.TryParse(s, out ip) && + ip.AddressFamily == AddressFamily.InterNetworkV6) + return true; + + // Hostname or domain + return HostName.IsMatch(s); + + } + + + public static bool IsValidQualifiedClassName(string value, bool requireNamespace, bool allowVerbatimIdentifiers) + { + if (string.IsNullOrWhiteSpace(value)) + return false; + + string s = value.Trim(); + + if (s.Length == 0) + return false; + + // Reject whitespace inside the name + for (int i = 0; i < s.Length; i++) + { + if (char.IsWhiteSpace(s[i])) + return false; + } + + // Optional source-style prefix: global::Namespace.Type + if (s.StartsWith("global::", StringComparison.Ordinal)) + s = s.Substring("global::".Length); + + string[] parts = s.Split('.'); + + if (requireNamespace && parts.Length < 2) + return false; + + for (int i = 0; i < parts.Length; i++) + { + if (!IsValidIdentifier(parts[i], allowVerbatimIdentifiers)) + return false; + } + + return true; + } + + private static bool IsValidIdentifier(string identifier, bool allowVerbatimIdentifier) + { + if (string.IsNullOrEmpty(identifier)) + return false; + + string id = identifier; + + if (id[0] == '@') + { + if (!allowVerbatimIdentifier) + return false; + + id = id.Substring(1); + + if (id.Length == 0) + return false; + } + + if (!IsIdentifierStartCharacter(id[0])) + return false; + + for (int i = 1; i < id.Length; i++) + { + if (!IsIdentifierPartCharacter(id[i])) + return false; + } + + // Reject reserved keywords unless written as @keyword + if (identifier[0] != '@' && ReservedKeywords.Contains(id)) + return false; + + return true; + } + + private static bool IsIdentifierStartCharacter(char ch) + { + if (ch == '_') + return true; + + UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(ch); + + return category == UnicodeCategory.UppercaseLetter || + category == UnicodeCategory.LowercaseLetter || + category == UnicodeCategory.TitlecaseLetter || + category == UnicodeCategory.ModifierLetter || + category == UnicodeCategory.OtherLetter || + category == UnicodeCategory.LetterNumber; + } + + private static bool IsIdentifierPartCharacter(char ch) + { + if (IsIdentifierStartCharacter(ch)) + return true; + + UnicodeCategory category = CharUnicodeInfo.GetUnicodeCategory(ch); + + return category == UnicodeCategory.DecimalDigitNumber || + category == UnicodeCategory.ConnectorPunctuation || + category == UnicodeCategory.NonSpacingMark || + category == UnicodeCategory.SpacingCombiningMark || + category == UnicodeCategory.Format; + } + } } diff --git a/Libraries/Esiur/Resource/Warehouse.cs b/Libraries/Esiur/Resource/Warehouse.cs index 7361453..dc1768f 100644 --- a/Libraries/Esiur/Resource/Warehouse.cs +++ b/Libraries/Esiur/Resource/Warehouse.cs @@ -82,8 +82,8 @@ public class Warehouse KeyList> _remoteTypeDefs = new KeyList>(); - //KeyList>> _remoteTypeDefs - // = new KeyList>>(); + // Domain -> Kind -> Type Name -> Proxy Type + KeyList>> _proxyTypeDefs = new(); Map _authenticationProviders = new Map(); @@ -579,14 +579,98 @@ public class Warehouse } - public void IsProxyType(Type type) + public Type TryGetProxyType(TypeDefKind kind, string domain, string name) { + if (!_proxyTypeDefs.ContainsKey(domain)) + return null; + if (!_proxyTypeDefs[domain].ContainsKey(kind)) + return null; + + if (!_proxyTypeDefs[domain][kind].ContainsKey(name)) + return null; + + return _proxyTypeDefs[domain][kind][name]; } + public Type GetProxyType(TypeDefKind kind, string domain, string name) + { + if (!_proxyTypeDefs.ContainsKey(domain)) + throw new Exception($"No proxy types registered for domain {domain}."); + + + if (!_proxyTypeDefs[domain].ContainsKey(kind)) + throw new Exception($"No proxy types registered for kind {kind} in domain {domain}."); + + if (!_proxyTypeDefs[domain][kind].ContainsKey(name)) + throw new Exception($"No proxy type registered with name {name} for kind {kind} in domain {domain}."); + + + return _proxyTypeDefs[domain][kind][name]; + } + + public void RegisterProxyType(Type type) { + // make sure the type has remote attribute + var remoteAttr = type.GetCustomAttribute(); + if (remoteAttr == null) + throw new Exception("Proxy type must have Remote attribute."); + + //@TODO should add this check t the RemoteAttribute class and use it here, but for now, we will just check the domain and full name format here. + if (!remoteAttr.AreValidDomains()) + throw new Exception("Invalid domain in Remote attribute."); + + if (!remoteAttr.IsValidFullName()) + throw new Exception("Invalid full name in Remote attribute."); + + + // make sure the type implements IResource or IRecord + if (Codec.ImplementsInterface(type, typeof(IRecord))) + { + foreach (var domain in remoteAttr.Domains) + { + if (!_proxyTypeDefs.ContainsKey(domain)) + _proxyTypeDefs.Add(domain, new KeyList>()); + + if (!_proxyTypeDefs[domain].ContainsKey(TypeDefKind.Record)) + _proxyTypeDefs[domain][TypeDefKind.Record] = new KeyList(); + + _proxyTypeDefs[domain][TypeDefKind.Record][remoteAttr.FullName] = type; + } + } + else if (Codec.InheritsClass(type, typeof(EpResource))) + { + foreach (var domain in remoteAttr.Domains) + { + + if (!_proxyTypeDefs.ContainsKey(domain)) + _proxyTypeDefs.Add(domain, new KeyList>()); + + if (!_proxyTypeDefs[domain].ContainsKey(TypeDefKind.Resource)) + _proxyTypeDefs[domain][TypeDefKind.Resource] = new KeyList(); + + _proxyTypeDefs[domain][TypeDefKind.Resource][remoteAttr.FullName] = type; + } + } + else if (type.IsEnum) + { + foreach (var domain in remoteAttr.Domains) + { + if (!_proxyTypeDefs.ContainsKey(domain)) + _proxyTypeDefs.Add(domain, new KeyList>()); + + if (!_proxyTypeDefs[domain].ContainsKey(TypeDefKind.Enum)) + _proxyTypeDefs[domain][TypeDefKind.Enum] = new KeyList(); + + _proxyTypeDefs[domain][TypeDefKind.Enum][remoteAttr.FullName] = type; + } + } + else + { + throw new Exception("Proxy type must implement IResource or IRecord or be an enum."); + } } /// @@ -759,14 +843,14 @@ public class Warehouse return _remoteTypeDefs[domain].Values.FirstOrDefault(x => x.Name == typeName); } - public TypeDef GetRemoteTypeDefByType(Type type) - { - var remoteAttr = type.GetCustomAttribute(); + //public TypeDef GetRemoteTypeDefByType(Type type) + //{ + // var remoteAttr = type.GetCustomAttribute(); - if (remoteAttr == null) return null; + // if (remoteAttr == null) return null; - return GetRemoteTypeDefByName(remoteAttr.Domain, remoteAttr.FullName); - } + // return GetRemoteTypeDefByName(remoteAttr.Domain, remoteAttr.FullName); + //} /// /// Get a TypeDef by type name . If not in the warehouse, a new TypeDef is created and added to the warehouse. diff --git a/Tests/RPC/Client/EsiurTest.cs b/Tests/RPC/Client/EsiurTest.cs index c48f802..e5f1da4 100644 --- a/Tests/RPC/Client/EsiurTest.cs +++ b/Tests/RPC/Client/EsiurTest.cs @@ -16,10 +16,13 @@ namespace Esiur.Tests.RPC.Client var rt = new TestResults(); using var mon = new PerProcessNetMonitor(Process.GetCurrentProcess().Id); - //mon.Start(); + mon.Start(); Console.WriteLine($"\n== Esiur @ {address} =="); + // register proxy types + Initialization.RegisterTypes(Warehouse.Default); + var service = await Warehouse.Default.Get(address); var sock = service.ResourceConnection.Socket as TcpSocket; diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Address.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Address.g.cs index 433bde7..f7b1b5b 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Address.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Address.g.cs @@ -6,7 +6,7 @@ using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Address", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Address", "localhost")] [Export] public class Address : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Attachment.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Attachment.g.cs index 54db510..5b39143 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Attachment.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Attachment.g.cs @@ -6,7 +6,7 @@ using Google.Protobuf; using System; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Attachment", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Attachment", "localhost")] [Export] public class Attachment : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.BusinessDocument.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.BusinessDocument.g.cs index dac3dd8..cb769be 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.BusinessDocument.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.BusinessDocument.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.BusinessDocument", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.BusinessDocument", "localhost")] [Export] public class BusinessDocument : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Currency.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Currency.g.cs index 5ea7136..5869f25 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Currency.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Currency.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Currency", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Currency", "localhost")] [Export] public enum Currency { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocType.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocType.g.cs index f63fea5..0838287 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocType.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocType.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.DocType", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.DocType", "localhost")] [Export] public enum DocType { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocumentHeader.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocumentHeader.g.cs index f88bd5a..a2ec6fd 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocumentHeader.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.DocumentHeader.g.cs @@ -6,7 +6,7 @@ using Google.Protobuf; using System; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.DocumentHeader", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.DocumentHeader", "localhost")] [Export] public class DocumentHeader : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Kind.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Kind.g.cs index 0ccc1ef..36c61bc 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Kind.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Kind.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Kind", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Kind", "localhost")] [Export] public enum Kind { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineItem.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineItem.g.cs index 73c2748..7c36aab 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineItem.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineItem.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.LineItem", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.LineItem", "localhost")] [Export] public class LineItem : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineType.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineType.g.cs index 63e17d6..7d0e199 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineType.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.LineType.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.LineType", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.LineType", "localhost")] [Export] public enum LineType { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Party.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Party.g.cs index 950939e..b99a318 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Party.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Party.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Party", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Party", "localhost")] [Export] public class Party : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Payment.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Payment.g.cs index 8da1c94..a089aaf 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Payment.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Payment.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Payment", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Payment", "localhost")] [Export] public class Payment : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.PaymentMethod.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.PaymentMethod.g.cs index 9fdbd6a..860652a 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.PaymentMethod.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.PaymentMethod.g.cs @@ -5,7 +5,7 @@ using Esiur.Data; using Esiur.Protocol; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.PaymentMethod", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.PaymentMethod", "localhost")] [Export] public enum PaymentMethod { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Service.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Service.g.cs index b291c7e..46bf3de 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Service.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Service.g.cs @@ -6,7 +6,7 @@ using Esiur.Protocol; #nullable enable namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Service", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Service", "localhost")] public class Service : EpResource { public Service(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) { } diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.TestObject.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.TestObject.g.cs index aae5fe5..9b07aae 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.TestObject.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.TestObject.g.cs @@ -6,7 +6,7 @@ using Esiur.Protocol; #nullable enable namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.TestObject", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.TestObject", "localhost")] public class TestObject : EpResource { public TestObject(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) { } diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Variant.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Variant.g.cs index e74d25c..6975abd 100644 --- a/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Variant.g.cs +++ b/Tests/RPC/Client/Model/Esiur/Esiur.Tests.RPC.EsiurServer.Variant.g.cs @@ -6,7 +6,7 @@ using Google.Protobuf; using System; namespace Esiur.Tests.RPC.EsiurServer { - [Remote("Esiur.Tests.RPC.EsiurServer.Variant", "")] + [Remote("Esiur.Tests.RPC.EsiurServer.Variant", "localhost")] [Export] public class Variant : IRecord { diff --git a/Tests/RPC/Client/Model/Esiur/Esiur.g.cs b/Tests/RPC/Client/Model/Esiur/Esiur.g.cs deleted file mode 100644 index 3a25317..0000000 --- a/Tests/RPC/Client/Model/Esiur/Esiur.g.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - namespace Esiur { - public static class Generated { - public static Type[] Resources {get;} = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.Service),typeof(Esiur.Tests.RPC.EsiurServer.TestObject) }; - public static Type[] Records { get; } = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.BusinessDocument),typeof(Esiur.Tests.RPC.EsiurServer.Attachment),typeof(Esiur.Tests.RPC.EsiurServer.Party),typeof(Esiur.Tests.RPC.EsiurServer.Address),typeof(Esiur.Tests.RPC.EsiurServer.DocumentHeader),typeof(Esiur.Tests.RPC.EsiurServer.LineItem),typeof(Esiur.Tests.RPC.EsiurServer.Variant),typeof(Esiur.Tests.RPC.EsiurServer.Payment) }; - public static Type[] Enums { get; } = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.Currency),typeof(Esiur.Tests.RPC.EsiurServer.DocType),typeof(Esiur.Tests.RPC.EsiurServer.Kind),typeof(Esiur.Tests.RPC.EsiurServer.LineType),typeof(Esiur.Tests.RPC.EsiurServer.PaymentMethod) }; - } -} \ No newline at end of file diff --git a/Tests/RPC/Client/Model/Esiur/Initialization.g.cs b/Tests/RPC/Client/Model/Esiur/Initialization.g.cs new file mode 100644 index 0000000..d74b830 --- /dev/null +++ b/Tests/RPC/Client/Model/Esiur/Initialization.g.cs @@ -0,0 +1,24 @@ +using Esiur.Resource; +using System; +namespace Esiur.Tests.RPC.EsiurServer +{ + public static class Initialization + { + public static Type[] Resources { get; } = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.Service), typeof(Esiur.Tests.RPC.EsiurServer.TestObject) }; + public static Type[] Records { get; } = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.BusinessDocument), typeof(Esiur.Tests.RPC.EsiurServer.Attachment), typeof(Esiur.Tests.RPC.EsiurServer.Party), typeof(Esiur.Tests.RPC.EsiurServer.Address), typeof(Esiur.Tests.RPC.EsiurServer.DocumentHeader), typeof(Esiur.Tests.RPC.EsiurServer.LineItem), typeof(Esiur.Tests.RPC.EsiurServer.Variant), typeof(Esiur.Tests.RPC.EsiurServer.Payment) }; + public static Type[] Enums { get; } = new Type[] { typeof(Esiur.Tests.RPC.EsiurServer.Currency), typeof(Esiur.Tests.RPC.EsiurServer.DocType), typeof(Esiur.Tests.RPC.EsiurServer.Kind), typeof(Esiur.Tests.RPC.EsiurServer.LineType), typeof(Esiur.Tests.RPC.EsiurServer.PaymentMethod) }; + + + public static void RegisterTypes(Warehouse warehouse) + { + foreach(var type in Resources) + warehouse.RegisterProxyType(type); + + foreach(var type in Records) + warehouse.RegisterProxyType(type); + + foreach(var type in Enums) + warehouse.RegisterProxyType(type); + } + } +} \ No newline at end of file