2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 22:48:42 +00:00
This commit is contained in:
2026-06-08 16:15:57 +03:00
parent 8143da2eee
commit 340798a5fa
111 changed files with 20647 additions and 27 deletions
@@ -0,0 +1,10 @@
using System;
namespace Esiur
{
public static class Generated
{
public static Type[] Resources { get; } = new Type[] { typeof(RPC.EsiurTest.Service), typeof(RPC.EsiurTest.TestObject) };
public static Type[] Records { get; } = new Type[] { typeof(RPC.EsiurTest.BusinessDocument), typeof(RPC.EsiurTest.Attachment), typeof(RPC.EsiurTest.Party), typeof(RPC.EsiurTest.Address), typeof(RPC.EsiurTest.DocumentHeader), typeof(RPC.EsiurTest.LineItem), typeof(RPC.EsiurTest.Variant), typeof(RPC.EsiurTest.Payment) };
public static Type[] Enums { get; } = new Type[] { typeof(RPC.EsiurTest.Currency), typeof(RPC.EsiurTest.DocType), typeof(RPC.EsiurTest.Kind), typeof(RPC.EsiurTest.LineType), typeof(RPC.EsiurTest.PaymentMethod) };
}
}
@@ -0,0 +1,84 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("0f8f447ee993847189b2c1ad6f83931a")]
[Export]
public class Address : IRecord
{
[Annotation("String")]
public string City { get; set; }
[Annotation("String")]
public string Country { get; set; }
[Annotation("String")]
public string Line1 { get; set; }
[Annotation("String")]
public string? Line2 { get; set; }
[Annotation("String")]
public string? PostalCode { get; set; }
[Annotation("String")]
public string Region { get; set; }
public override bool Equals(object? obj)
{
var other = obj as Address;
if (other == null) return false;
if (other.Line1 != Line1) return false;
if (other.Line2 != Line2) return false;
if (other.PostalCode != PostalCode) return false;
if (other.City != City) return false;
if (other.Country != Country) return false;
if (other.Region != Region) return false;
return true;
}
public SharedModel.Address ToShared()
{
return new SharedModel.Address()
{
City = City,
Country = Country,
Line1 = Line1,
Line2 = Line2,
PostalCode = PostalCode,
Region = Region,
};
}
public Echo.Model.Grpc.Address ToGrpc()
{
return new Echo.Model.Grpc.Address()
{
City = City,
Country = Country,
Line1 = Line1,
Line2 = Line2 ?? "",
PostalCode = PostalCode ?? "",
Region = Region,
};
}
public Echo.ThriftModel.Address ToThrift()
{
return new Echo.ThriftModel.Address()
{
City = City,
Country = Country,
Line1 = Line1,
Line2 = Line2,
PostalCode = PostalCode,
Region = Region,
};
}
}
}
@@ -0,0 +1,62 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
using Google.Protobuf;
namespace RPC.EsiurTest
{
[TypeId("4befaa686f038a2885268fca4cbf3c2c")]
[Export]
public class Attachment : IRecord
{
[Annotation("Byte[]")]
public byte[] Data { get; set; }
[Annotation("String")]
public string MimeType { get; set; }
[Annotation("String")]
public string Name { get; set; }
public override bool Equals(object? obj)
{
var other = obj as Attachment;
if (Name != other.Name) return false;
if (MimeType != other.MimeType) return false;
if (!(Data.SequenceEqual(other.Data))) return false;
return true;
}
public SharedModel.Attachment ToShared()
{
return new SharedModel.Attachment()
{
Data = Data,
MimeType = MimeType,
Name = Name,
};
}
public Echo.Model.Grpc.Attachment ToGrpc()
{
return new Echo.Model.Grpc.Attachment()
{
Data = ByteString.CopyFrom(Data),
MimeType = MimeType,
Name = Name,
};
}
public Echo.ThriftModel.Attachment ToThrift()
{
return new Echo.ThriftModel.Attachment()
{
Data = Data,
MimeType = MimeType,
Name = Name,
};
}
}
}
@@ -0,0 +1,145 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
using Google.Protobuf;
using Google.Protobuf.Collections;
namespace RPC.EsiurTest
{
[TypeId("9a34d22890e787b48133a2a61ac84ad8")]
[Export]
public class BusinessDocument : IRecord
{
[Annotation("Attachment[]")]
public RPC.EsiurTest.Attachment[] Attachments { get; set; }
[Annotation("Party")]
public RPC.EsiurTest.Party Buyer { get; set; }
[Annotation("DocumentHeader")]
public RPC.EsiurTest.DocumentHeader Header { get; set; }
[Annotation("LineItem[]")]
public RPC.EsiurTest.LineItem[] Items { get; set; }
[Annotation("Payment[]")]
public RPC.EsiurTest.Payment[] Payments { get; set; }
[Annotation("Int32[]")]
public int[] RiskScores { get; set; }
[Annotation("Party")]
public RPC.EsiurTest.Party Seller { get; set; }
public override bool Equals(object? obj)
{
var other = obj as BusinessDocument;
if (other == null)
return false;
if (!Header.Equals(other.Header))
return false;
if (!Seller.Equals(other.Seller))
return false;
if (!Buyer.Equals(other.Buyer))
return false;
if (Items != null)
for (var i = 0; i < Items.Length; i++)
if (!Items[i].Equals(other.Items[i]))
return false;
if (Payments != null)
for (var i = 0; i < Payments.Length; i++)
if (!Payments[i].Equals(other.Payments[i]))
return false;
if (Attachments != null)
for (var i = 0; i < Attachments.Length; i++)
if (!Attachments[i].Equals(other.Attachments[i]))
return false;
if (!RiskScores.SequenceEqual(other.RiskScores))
return false;
return true;
}
public SharedModel.BusinessDocument ToShared()
{
return new SharedModel.BusinessDocument()
{
Attachments = Attachments?.Select(x=>x.ToShared()).ToArray() ?? null,
Buyer = Buyer.ToShared(),
Header = Header.ToShared(),
Items = Items.Select(x=>x.ToShared()).ToArray(),
Payments = Payments.Select(x=>x.ToShared()).ToArray(),
RiskScores = RiskScores,
Seller = Seller.ToShared(),
};
}
public Echo.ThriftModel.BusinessDocument ToThrift()
{
var rt = new Echo.ThriftModel.BusinessDocument();
if (Header != null)
rt.Header = Header.ToThrift();
if (Buyer != null)
rt.Buyer = Buyer.ToThrift();
if (Seller != null)
rt.Seller = Seller.ToThrift();
if (Attachments != null)
rt.Attachments = Attachments.Select(x=>x.ToThrift()).ToList();
if (RiskScores != null)
rt.RiskScores = RiskScores.ToList();
if (Items != null)
rt.Items = Items.Select(x => x.ToThrift()).ToList();
if (Payments != null)
rt.Payments = Payments.Select(x => x.ToThrift()).ToList();
return rt;
}
public Echo.Model.Grpc.BusinessDocument ToGrpc()
{
var rt = new Echo.Model.Grpc.BusinessDocument()
{
Header = Header.ToGrpc(),
Buyer = Buyer.ToGrpc(),
Seller = Seller.ToGrpc(),
};
if (Payments != null)
foreach (var p in Payments)
rt.Payments.Add(p.ToGrpc());
if (Attachments != null)
foreach (var p in Attachments)
rt.Attachments.Add(p.ToGrpc());
if (Items != null)
foreach (var p in Items)
rt.Items.Add(p.ToGrpc());
if (RiskScores != null)
foreach (var p in RiskScores)
rt.RiskScores.Add(p);
return rt;
}
}
}
@@ -0,0 +1,20 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("c44e42333dfd8d3485bb2a79fd7a9f6f")]
[Export]
public enum Currency
{
CNH = 1,
EUR = 3,
GBP = 5,
IQD = 0,
JPY = 4,
USD = 2
}
}
@@ -0,0 +1,18 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("6ded4eca74c8886a85a74e082770be4b")]
[Export]
public enum DocType
{
CreditNote = 3,
Invoice = 2,
Order = 1,
Quote = 0
}
}
@@ -0,0 +1,114 @@
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
using Esiur.Resource;
using Google.Protobuf;
using System;
namespace RPC.EsiurTest
{
[TypeId("4631164f62d489e68ffab70e20b421f2")]
[Export]
public class DocumentHeader : IRecord
{
[Annotation("DateTime")]
public DateTime CreatedAt { get; set; }
[Annotation("Currency")]
public RPC.EsiurTest.Currency Currency { get; set; }
[Annotation("Byte[]")]
public byte[] DocId { get; set; }
[Annotation("Dictionary`2")]
public Map<string, RPC.EsiurTest.Variant> Meta { get; set; }
[Annotation("String")]
public string? Notes { get; set; }
[Annotation("DocType")]
public RPC.EsiurTest.DocType Type { get; set; }
[Annotation("Nullable`1?")]
public DateTime? UpdatedAt { get; set; }
[Annotation("Int32")]
public int Version { get; set; }
public SharedModel.DocumentHeader ToShared()
{
return new SharedModel.DocumentHeader()
{
CreatedAt = CreatedAt,
DocId = DocId,
Meta = Meta.ToDictionary(x=>x.Key, v=>v.Value.ToShared()),
Notes = Notes,
Currency = Enum.Parse<SharedModel.Currency>(Currency.ToString(), true),
UpdatedAt = UpdatedAt,
Version = Version,
Type = Enum.Parse<SharedModel.DocType>(Type.ToString(), true)
};
}
public Echo.ThriftModel.DocumentHeader ToThrift()
{
var rt = new Echo.ThriftModel.DocumentHeader()
{
DocId = DocId,
CreatedAt = CreatedAt.Ticks,
Currency = Enum.Parse< Echo.ThriftModel.Currency>(Currency.ToString(), true),
Type = Enum.Parse< Echo.ThriftModel.DocType>(Type.ToString(), true),
Version = Version,
Meta = Meta.ToDictionary(x=>x.Key, x=>x.Value.ToThrift())
};
if (UpdatedAt != null)
rt.UpdatedAt = UpdatedAt.Value.Ticks;
if (Notes != null)
rt.Notes = Notes;
return rt;
}
public Echo.Model.Grpc.DocumentHeader ToGrpc()
{
var hdr = new Echo.Model.Grpc.DocumentHeader();
hdr.DocId = ByteString.CopyFrom(DocId);
hdr.CreatedAt = CreatedAt.Ticks;
hdr.Currency = Enum.Parse<Echo.Model.Grpc.Currency>(Currency.ToString(), true);
hdr.Version = Version;
hdr.Notes = Notes;
foreach (var mt in Meta)
hdr.Meta.Add(mt.Key, mt.Value.ToGrpc());
return hdr;
}
public override bool Equals(object? obj)
{
var other = obj as DocumentHeader;
if (other == null) return false;
if (!DocId.SequenceEqual(other.DocId)) return false;
if (Type != other.Type) return false;
if (Version != other.Version) return false;
if (CreatedAt != other.CreatedAt) return false;
if (UpdatedAt != other.UpdatedAt) return false;
if (Currency != other.Currency) return false;
if (Notes != other.Notes) return false;
if (Meta != null)
foreach (var kv in Meta)
if (!other.Meta[kv.Key].Equals(kv.Value))
return false;
return true;
}
}
}
@@ -0,0 +1,24 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("32ae8265068382608399b7e427be37db")]
[Export]
public enum Kind
{
Bool = 1,
Bytes = 7,
DateTime = 8,
Decimal = 5,
Double = 4,
Guid = 9,
Int64 = 2,
Null = 0,
String = 6,
UInt64 = 3
}
}
@@ -0,0 +1,132 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("142f42b0e1a78c098f35fa935cde22c1")]
[Export]
public class LineItem : IRecord
{
[Annotation("String")]
public string Description { get; set; }
[Annotation("Nullable`1?")]
public double? Discount { get; set; }
[Annotation("Map`2")]
public Map<string, RPC.EsiurTest.Variant> Ext { get; set; }
[Annotation("Int32")]
public int LineNo { get; set; }
[Annotation("Double")]
public double Qty { get; set; }
[Annotation("String")]
public string QtyUnit { get; set; }
[Annotation("String")]
public string SKU { get; set; }
[Annotation("LineType")]
public RPC.EsiurTest.LineType Type { get; set; }
[Annotation("Double")]
public double UnitPrice { get; set; }
[Annotation("Nullable`1?")]
public double? VatRate { get; set; }
public SharedModel.LineItem ToShared()
{
return new SharedModel.LineItem()
{
Description = Description,
Discount = Discount,
Ext = Ext.ToDictionary(k => k.Key, v => v.Value.ToShared()),
LineNo = LineNo,
Qty = Qty,
QtyUnit = QtyUnit,
SKU = SKU,
Type = Enum.Parse<SharedModel.LineType>(Type.ToString(), true),
UnitPrice = UnitPrice,
VatRate = VatRate
};
}
public Echo.ThriftModel.LineItem ToThrift()
{
var rt = new Echo.ThriftModel.LineItem()
{
Description = Description,
LineNo = LineNo,
Qty = Qty,
UnitPrice = UnitPrice,
QtyUnit = QtyUnit,
Sku = SKU,
Type = Enum.Parse<Echo.ThriftModel.LineType>(Type.ToString(), true),
};
if (Discount != null)
rt.Discount = Discount.Value;
if (VatRate != null)
rt.VatRate = VatRate.Value;
if (Ext != null)
rt.Ext = Ext.ToDictionary(x => x.Key, v => v.Value.ToThrift());
return rt;
}
public Echo.Model.Grpc.LineItem ToGrpc()
{
var rt = new Echo.Model.Grpc.LineItem()
{
Description = Description,
Discount = Discount ?? 0,
LineNo = LineNo,
Qty = Qty,
UnitPrice = UnitPrice,
QtyUnit = QtyUnit,
Sku = SKU,
Type = Enum.Parse<Echo.Model.Grpc.LineType>(Type.ToString(), true),
VatRate = VatRate ?? 0,
};
if (Ext != null)
{
foreach (var kv in Ext)
rt.Ext.Add(kv.Key, kv.Value.ToGrpc());
}
return rt;
}
public override bool Equals(object? obj)
{
var other = obj as LineItem;
if (other == null) return false;
if (other.LineNo != LineNo) return false;
if (other.SKU != SKU) return false;
if (other.Description != Description) return false;
if (other.Discount != Discount) return false;
if (other.QtyUnit != QtyUnit) return false;
if (other.Type != Type) return false;
if (other.VatRate != VatRate) return false;
if (other.UnitPrice != UnitPrice) return false;
if (Ext != null)
{
foreach (var kv in Ext)
if (!other.Ext[kv.Key].Equals(kv.Value))
return false;
}
return true;
}
}
}
@@ -0,0 +1,18 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("7e474e8826e288f28bddddf69782c580")]
[Export]
public enum LineType
{
Discount = 2,
Product = 0,
Service = 1,
Shipping = 3
}
}
@@ -0,0 +1,93 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("44fff9c7bd9b86f580bf479a64cb84af")]
[Export]
public class Party : IRecord
{
[Annotation("Address")]
public RPC.EsiurTest.Address Address { get; set; }
[Annotation("String")]
public string Email { get; set; }
[Annotation("UInt64")]
public ulong Id { get; set; }
[Annotation("String")]
public string Name { get; set; }
[Annotation("String")]
public string Phone { get; set; }
[Annotation("String")]
public string PreferredLanguage { get; set; }
[Annotation("String")]
public string TaxId { get; set; }
public SharedModel.Party ToShared()
{
return new SharedModel.Party()
{
Address = Address.ToShared(),
Email = Email,
Id = Id,
Name = Name,
Phone = Phone,
PreferredLanguage = PreferredLanguage,
TaxId = TaxId,
};
}
public Echo.ThriftModel.Party ToThrift()
{
return new Echo.ThriftModel.Party()
{
Address = Address.ToThrift(),
Email = Email,
Id = (long)Id,
Name = Name,
Phone = Phone,
PreferredLanguage = PreferredLanguage,
TaxId = TaxId
};
}
public Echo.Model.Grpc.Party ToGrpc()
{
return new Echo.Model.Grpc.Party()
{
Address = Address.ToGrpc(),
Email = Email,
Id = Id,
Name = Name,
Phone = Phone,
PreferredLanguage = PreferredLanguage ?? "",
TaxId = TaxId ?? "",
};
}
public override bool Equals(object? obj)
{
var other = obj as Party;
if (other == null) return false;
if (other.Id != Id) return false;
if (other.TaxId != TaxId) return false;
if (!other.Address.Equals(Address)) return false;
if (other.Email != Email) return false;
if (other.Name != Name) return false;
if (other.Phone != Phone) return false;
if (other.PreferredLanguage != PreferredLanguage) return false;
return true;
}
}
}
@@ -0,0 +1,87 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("f172196340298b8586fed434c72bc158")]
[Export]
public class Payment : IRecord
{
[Annotation("Double")]
public double Amount { get; set; }
[Annotation("Currency")]
public RPC.EsiurTest.Currency Currency { get; set; }
[Annotation("Nullable`1?")]
public double? Fee { get; set; }
[Annotation("PaymentMethod")]
public RPC.EsiurTest.PaymentMethod Method { get; set; }
[Annotation("String")]
public string Reference { get; set; }
[Annotation("DateTime")]
public DateTime Timestamp { get; set; }
public SharedModel.Payment ToShared()
{
return new SharedModel.Payment()
{
Amount = Amount,
Currency = Enum.Parse<SharedModel.Currency>(Currency.ToString(), true),
Method = Enum.Parse<SharedModel.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp,
Fee = Fee,
};
}
public Echo.ThriftModel.Payment ToThrift()
{
var rt= new Echo.ThriftModel.Payment()
{
Amount = Amount,
Currency = Enum.Parse<Echo.ThriftModel.Currency>(Currency.ToString(), true),
Method = Enum.Parse<Echo.ThriftModel.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp.Ticks,
};
if (Fee != null)
rt.Fee = Fee.Value;
return rt;
}
public Echo.Model.Grpc.Payment ToGrpc()
{
return new Echo.Model.Grpc.Payment()
{
Amount = Amount,
Currency = Enum.Parse<Echo.Model.Grpc.Currency>(Currency.ToString(), true),
Fee = Fee ?? 0,
Method = Enum.Parse<Echo.Model.Grpc.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp.Ticks,
};
}
public override bool Equals(object? obj)
{
var other = obj as Payment;
if (other == null) return false;
if (Method != other.Method) return false;
if (Amount != other.Amount) return false;
if (Reference != other.Reference) return false;
if (Fee != other.Fee) return false;
return true;
}
}
}
@@ -0,0 +1,19 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("fadfe3764f808d7e839fef5275490dd7")]
[Export]
public enum PaymentMethod
{
Card = 1,
Cash = 0,
Crypto = 3,
Other = 4,
Wire = 2
}
}
@@ -0,0 +1,196 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
#nullable enable
namespace RPC.EsiurTest
{
//{ab8e681b-61d9-8fb7-8c63-bbded15457e1}
[TypeId("f7e00be8881d88d68a8a2dc2d3a4b3d1")]
public class Service : EpResource
{
public Service(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) { }
public Service() { }
[Annotation("([Int32] count,[Int32] size,[Int32] delay) -> AsyncReply`1")]
[Export]
public AsyncReply<byte[]> ChunkTest(int count, int size, int delay)
{
var args = new Map<byte, object>() { [0] = count, [1] = size, [2] = delay };
var rt = new AsyncReply<byte[]>();
_Invoke(0, args)
.Then(x => rt.Trigger((byte[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Byte[]] payload) -> Byte[]")]
[Export]
public AsyncReply<byte[]> EchoBytes(byte[] payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<byte[]>();
_Invoke(1, args)
.Then(x => rt.Trigger((byte[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([BusinessDocument[]] payload) -> BusinessDocument[]")]
[Export]
public AsyncReply<RPC.EsiurTest.BusinessDocument[]> EchoDocuments(RPC.EsiurTest.BusinessDocument[] payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<RPC.EsiurTest.BusinessDocument[]>();
_Invoke(2, args)
.Then(x => rt.Trigger((RPC.EsiurTest.BusinessDocument[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([DocType[]] payload) -> DocType[]")]
[Export]
public AsyncReply<RPC.EsiurTest.DocType[]> EchoEnumArray(RPC.EsiurTest.DocType[] payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<RPC.EsiurTest.DocType[]>();
_Invoke(3, args)
.Then(x => rt.Trigger((RPC.EsiurTest.DocType[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32[]] payload) -> Int32[]")]
[Export]
public AsyncReply<int[]> EchoIntArray(int[] payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<int[]>();
_Invoke(4, args)
.Then(x => rt.Trigger((int[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Map`2] payload) -> Map`2")]
[Export]
public AsyncReply<Map<string, RPC.EsiurTest.BusinessDocument>> EchoMap(Map<string, RPC.EsiurTest.BusinessDocument> payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<Map<string, RPC.EsiurTest.BusinessDocument>>();
_Invoke(5, args)
.Then(x => rt.Trigger((Map<string, RPC.EsiurTest.BusinessDocument>)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([String[]] payload) -> String[]")]
[Export]
public AsyncReply<string[]> EchoStringArray(string[] payload)
{
var args = new Map<byte, object>() { [0] = payload };
var rt = new AsyncReply<string[]>();
_Invoke(6, args)
.Then(x => rt.Trigger((string[])x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] count,[Int32] size,[Int32] delay) -> Void")]
[Export]
public AsyncReply<object> EventTest(int count, int size, int delay)
{
var args = new Map<byte, object>() { [0] = count, [1] = size, [2] = delay };
var rt = new AsyncReply<object>();
_Invoke(7, args)
.Then(x => rt.Trigger((object)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] count,[Int32] size,[Int32] delay) -> Void")]
[Export]
public AsyncReply<object> PropertyChangeTest(int count, int size, int delay)
{
var args = new Map<byte, object>() { [0] = count, [1] = size, [2] = delay };
var rt = new AsyncReply<object>();
_Invoke(8, args)
.Then(x => rt.Trigger((object)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] interval,[Int32] count,[Double] localProbability,[Double] remoteProbability,[String] remoteHostLink) -> AsyncReply`1")]
[Export]
public AsyncReply<RPC.EsiurTest.TestObject> StartUpdates(int interval, int count, double localProbability, double remoteProbability, string remoteHostLink)
{
var args = new Map<byte, object>() { [0] = interval, [1] = count, [2] = localProbability, [3] = remoteProbability, [4] = remoteHostLink };
var rt = new AsyncReply<RPC.EsiurTest.TestObject>();
_Invoke(9, args)
.Then(x => rt.Trigger((RPC.EsiurTest.TestObject)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] interval,[Int32] count,[Double] localProbability) -> AsyncReply`1")]
[Export]
public AsyncReply<RPC.EsiurTest.TestObject> StartUpdatesLocal(int interval, int count, double localProbability)
{
var args = new Map<byte, object>() { [0] = interval, [1] = count, [2] = localProbability };
var rt = new AsyncReply<RPC.EsiurTest.TestObject>();
_Invoke(10, args)
.Then(x => rt.Trigger((RPC.EsiurTest.TestObject)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] interval,[Int32] count,[Double] remoteProbability,[String] remoteNode,[String] remoteLink) -> AsyncReply`1")]
[Export]
public AsyncReply<RPC.EsiurTest.TestObject> StartUpdatesMirror(int interval, int count, double remoteProbability, string remoteNode, string remoteLink)
{
var args = new Map<byte, object>() { [0] = interval, [1] = count, [2] = remoteProbability, [3] = remoteNode, [4] = remoteLink };
var rt = new AsyncReply<RPC.EsiurTest.TestObject>();
_Invoke(11, args)
.Then(x => rt.Trigger((RPC.EsiurTest.TestObject)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("([Int32] interval,[Int32] count,[Double] remoteProbability,[String] remoteLink) -> AsyncReply`1")]
[Export]
public AsyncReply<RPC.EsiurTest.TestObject> StartUpdatesRemote(int interval, int count, double remoteProbability, string remoteLink)
{
var args = new Map<byte, object>() { [0] = interval, [1] = count, [2] = remoteProbability, [3] = remoteLink };
var rt = new AsyncReply<RPC.EsiurTest.TestObject>();
_Invoke(12, args)
.Then(x => rt.Trigger((RPC.EsiurTest.TestObject)x))
.Error(x => rt.TriggerError(x))
.Chunk(x => rt.TriggerChunk(x));
return rt;
}
[Annotation("Byte[]")]
[Export]
public byte[] MessageToChange
{
get => (byte[])_properties[0];
set => SetResourceProperty(0, value);
}
[Annotation("Object")]
[Export]
public object TestProperty
{
get => (object)_properties[1];
set => SetResourceProperty(1, value);
}
protected override void _EmitEventByIndex(byte index, object args)
{
switch (index)
{
case 0: MessageUpdated?.Invoke((byte[])args); break;
}
}
[Export] public event ResourceEventHandler<byte[]> MessageUpdated;
}
}
@@ -0,0 +1,121 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
using Google.Protobuf;
namespace RPC.EsiurTest
{
[TypeId("91ed22c5c53e846181f799dc76ddd93c")]
[Export]
public class Variant : IRecord
{
[Annotation("Nullable`1?")]
public bool? Bool { get; set; }
[Annotation("Byte[]")]
public byte[] Bytes { get; set; }
[Annotation("Nullable`1?")]
public DateTime? Dt { get; set; }
[Annotation("Nullable`1?")]
public double? F64 { get; set; }
[Annotation("Byte[]")]
public byte[] Guid { get; set; }
[Annotation("Nullable`1?")]
public long? I64 { get; set; }
[Annotation("String")]
public string Str { get; set; }
[Annotation("Kind")]
public RPC.EsiurTest.Kind Tag { get; set; }
[Annotation("Nullable`1?")]
public ulong? U64 { get; set; }
public RPC.SharedModel.Variant ToShared()
{
return new SharedModel.Variant()
{
Bool = Bool,
Bytes = Bytes,
Dt = Dt,
F64 = F64,
Guid = Guid,
I64 = I64,
Str = Str,
Tag = Enum.Parse<SharedModel.Kind>(Tag.ToString(), true),
U64 = U64
};
}
public Echo.Model.Grpc.Variant ToGrpc()
{
return new Echo.Model.Grpc.Variant()
{
BoolVal = Bool ?? false,
BytesVal = ByteString.CopyFrom(Bytes ?? new byte[0]),
DtVal = Dt?.Ticks ?? 0,
F64Val = F64 ?? 0,
GuidVal = ByteString.CopyFrom(Guid ?? new byte[0]),
I64Val = I64 ?? 0,
StrVal = Str,
Tag = Enum.Parse<Echo.Model.Grpc.Kind>(Tag.ToString(), true),
U64Val = U64 ?? 0,
};
}
public Echo.ThriftModel.Variant ToThrift()
{
var rt = new Echo.ThriftModel.Variant()
{
Tag = Enum.Parse<Echo.ThriftModel.Kind>(Tag.ToString(), true),
};
if (Bool != null)
rt.BoolVal = Bool.Value;
if (Bytes != null)
rt.BytesVal = Bytes;
if (Dt != null)
rt.DtVal = Dt.Value.Ticks;
if (F64 != null)
rt.F64Val = F64.Value;
if (Guid != null)
rt.GuidVal = Guid;
if (I64 != null)
rt.I64Val = I64.Value;
return rt;
}
public override bool Equals(object? obj)
{
var other = obj as Variant;
if (other == null) return false;
if (other.I64 != I64) return false;
if (other.U64 != U64) return false;
if (other.Bool != Bool) return false;
//if (other.Dec != Dec) return false;
if (other.Str != Str) return false;
if (Guid != null)
if (!other.Guid.SequenceEqual(Guid)) return false;
if (other.F64 != F64) return false;
if (other.Tag != Tag) return false;
if (Bytes != null)
if (!other.Bytes.SequenceEqual(Bytes)) return false;
if (other.Dt != Dt)
return false;
return true;
}
}
}
@@ -0,0 +1,37 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
#nullable enable
namespace RPC.EsiurTest
{
[TypeId("d90d3558e2b18d9a8f45707372ddf2c3")]
public class TestObject : EpResource
{
public TestObject(EpConnection connection, uint instanceId, ulong age, string link) : base(connection, instanceId, age, link) { }
public TestObject() { }
[Annotation("String")]
[Export]
public string Name
{
get => (string)properties[0];
set => SetResourceProperty(0, value);
}
[Annotation("Int32")]
[Export]
public int Size
{
get => (int)properties[1];
set => SetResourceProperty(1, value);
}
[Annotation("Object")]
[Export]
public object Value
{
get => (object)properties[2];
set => SetResourceProperty(2, value);
}
}
}