mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Ver 3
This commit is contained in:
@@ -33,13 +33,6 @@ public partial class MyService
|
||||
[Export] bool boolean = true;
|
||||
[Export] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
||||
|
||||
[Export]
|
||||
public MyGenericRecord<MyResource> GetGenericRecord()
|
||||
{
|
||||
return new MyGenericRecord<MyResource>() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 };
|
||||
}
|
||||
|
||||
[Export] public static string staticFunction(string name) => $"Hello {name}";
|
||||
|
||||
[Export] byte uInt8Test = 8;
|
||||
[Export] byte? uInt8Null = null;
|
||||
@@ -85,25 +78,33 @@ public partial class MyService
|
||||
|
||||
[Export] DateTime time = DateTime.Now;
|
||||
|
||||
[Export] public const double PI = Math.PI;
|
||||
|
||||
[Export] public MyService Me => this;
|
||||
|
||||
[Export] int PrivateInt32 { get; set; } = 99;
|
||||
|
||||
[Export("Object")] object objectTest = "String as object";
|
||||
|
||||
[Export] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
|
||||
|
||||
|
||||
[Export]
|
||||
Map<string, object> stringMap = new Map<string, object>()
|
||||
{
|
||||
["int"] = 33,
|
||||
["string"] = "Hello World"
|
||||
["Sequence"] = 123,
|
||||
["Message"] = "Hello World"
|
||||
};
|
||||
|
||||
[Export]
|
||||
Map<int, string> intStringMap = new()
|
||||
{
|
||||
[4] = "Abcd",
|
||||
[44] = "EfG"
|
||||
[3] = "EfG"
|
||||
};
|
||||
|
||||
|
||||
[Export("Object")] object objectTest = "object";
|
||||
|
||||
[Export] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
|
||||
|
||||
[Export]
|
||||
public PropertyContext<int> PropertyContext
|
||||
@@ -119,10 +120,10 @@ public partial class MyService
|
||||
int MyPasscode = 2025;
|
||||
public PropertyContext<int> Passcode
|
||||
{
|
||||
get => new((sender) => sender.Session.AuthorizedIdentity == "alice" ? MyPasscode : 0);
|
||||
get => new((sender) => sender.Session.RemoteIdentity == "alice" ? MyPasscode : 0);
|
||||
set
|
||||
{
|
||||
if (value.Connection.Session.AuthorizedIdentity != "alice")
|
||||
if (value.Connection.Session.RemoteIdentity != "alice")
|
||||
throw new Exception("Only Alice is allowed.");
|
||||
MyPasscode = value.Value;
|
||||
}
|
||||
@@ -159,9 +160,6 @@ public partial class MyService
|
||||
[Export]
|
||||
public void InvokeEvents(string msg, InvocationContext context)
|
||||
{
|
||||
//if (context.Connection.Session.AuthorizedAccount != "Alice")
|
||||
// throw new Exception("Only Alice is allowed.");
|
||||
|
||||
StringEvent?.Invoke(msg);
|
||||
ArrayEvent?.Invoke(new object[] { DateTime.UtcNow, "Event", msg });
|
||||
}
|
||||
@@ -207,9 +205,13 @@ public partial class MyService
|
||||
return record;
|
||||
}
|
||||
|
||||
[Export] public const double PI = Math.PI;
|
||||
|
||||
[Export] public MyService Me => this;
|
||||
[Export]
|
||||
public MyGenericRecord<MyResource> GetGenericRecord()
|
||||
{
|
||||
return new MyGenericRecord<MyResource>() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 };
|
||||
}
|
||||
|
||||
[Export] public static string staticFunction(string name) => $"Hello {name}";
|
||||
|
||||
[Export] int PrivateInt32 { get; set; } = 99;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class Program
|
||||
//TestSerialization(10.1d);
|
||||
//TestSerialization((byte)1);
|
||||
//TestSerialization((byte)2);
|
||||
TestSerialization(new int[] { 1, 2, 3, 4 });
|
||||
//TestSerialization(new int[] { 1, 2, 3, 4 });
|
||||
//var x = LogLevel.Warning;
|
||||
|
||||
//TestSerialization(LogLevel.Warning);
|
||||
@@ -213,18 +213,22 @@ class Program
|
||||
private static async void TestClient(IResource local)
|
||||
{
|
||||
|
||||
var con = await new Warehouse().Get<EpConnection>("EP://localhost", new EpConnectionConfig
|
||||
var con = await new Warehouse().Get<EpConnection>("EP://localhost", new EpConnectionContext
|
||||
{
|
||||
AutoReconnect = true,
|
||||
Username = "admin",
|
||||
Password = "admin",
|
||||
Authenticator = Authenticator
|
||||
//Username = "admin",
|
||||
//Password = "admin",
|
||||
Identity = "demo",
|
||||
AuthenticationProtocol = "hash"
|
||||
});
|
||||
|
||||
|
||||
dynamic remote = await con.Get("sys/service");
|
||||
var gr = await remote.GetGenericRecord();
|
||||
Console.WriteLine(gr);
|
||||
dynamic remote = await con.Get("sys/service");
|
||||
|
||||
TestObjectProps(local, remote);
|
||||
|
||||
//return;
|
||||
|
||||
//return;
|
||||
|
||||
Console.WriteLine("OK");
|
||||
@@ -236,11 +240,8 @@ class Program
|
||||
var temp = await con.Call("temp");
|
||||
Console.WriteLine("Temp: " + temp.GetHashCode());
|
||||
|
||||
//var template = await con.GetTemplateByClassName("Test.MyResource");
|
||||
|
||||
|
||||
TestObjectProps(local, remote);
|
||||
|
||||
|
||||
var opt = await remote.Optional(new { a1 = 22, a2 = 33, a4 = "What?" });
|
||||
Console.WriteLine(opt);
|
||||
|
||||
Reference in New Issue
Block a user