2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-26 21:13:13 +00:00
This commit is contained in:
2024-03-25 17:59:55 +03:00
parent 81f9f92755
commit 8ab0e811bd
21 changed files with 255 additions and 100 deletions

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Test
{
[Public]
[Export]
public class MyChildRecord : MyRecord
{
public string ChildName { get; set; }

View File

@ -10,11 +10,11 @@ namespace Test
[Resource]
public partial class MyChildResource : MyResource
{
[Public] string childName;
[Public("Hell2o")] public int ChildMethod(string childName) => 111;
[Public] public new string Hello() => "Hi from Child";
[Export] string childName;
[Export("Hell2o")] public int ChildMethod(string childName) => 111;
[Export] public new string Hello() => "Hi from Child";
[Public] public string HelloChild() => "Hi from Child";
[Export] public string HelloChild() => "Hi from Child";
}
}

View File

@ -10,10 +10,10 @@ namespace Test
{
public class MyGenericRecord<T> : IRecord where T : IResource
{
[Public] public int Start { get; set; }
[Public] public int Needed { get; set; }
[Public] public int Total { get; set; }
[Public] public T[] Results { get; set; }
[Export] public int Start { get; set; }
[Export] public int Needed { get; set; }
[Export] public int Total { get; set; }
[Export] public T[] Results { get; set; }
}
}

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Test
{
[Public]
[Export]
public class MyRecord:IRecord
{
public string Name { get; set; }

View File

@ -12,12 +12,12 @@ namespace Test
[Annotation("A", "B", "C", "D")]
public partial class MyResource
{
[Public][Annotation("Comment")] string description;
[Public] int categoryId;
[Export][Annotation("Comment")] string description;
[Export] int categoryId;
[Public] public string Hello() => "Hi";
[Export] public string Hello() => "Hi";
[Public] public string HelloParent() => "Hi from Parent";
[Export] public string HelloParent() => "Hi from Parent";
}
}

View File

@ -25,73 +25,73 @@ public enum SizeEnum:short
public partial class MyService
{
[Public] public event ResourceEventHandler<string> StringEvent;
[Public] public event ResourceEventHandler<object[]> ArrayEvent;
[Export] public event ResourceEventHandler<string> StringEvent;
[Export] public event ResourceEventHandler<object[]> ArrayEvent;
[Public] bool boolean = true;
[Public] bool[] booleanArray = new bool[] { true, false, true, false, true };
[Export] bool boolean = true;
[Export] bool[] booleanArray = new bool[] { true, false, true, false, true };
[Public]
[Export]
public MyGenericRecord<MyResource> GetGenericRecord()
{
return new MyGenericRecord<MyResource>() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 };
}
[Public] public static string staticFunction(string name) => $"Hello {name}";
[Export] public static string staticFunction(string name) => $"Hello {name}";
[Public] byte uInt8Test = 8;
[Public] byte? uInt8Null = null;
[Public] byte[] uInt8Array = new byte[] { 0, 1, 2, 3, 4, 5 };
[Public] byte?[] uInt8ArrayNull = new byte?[] { 0, null, 2, null, 4, null };
[Export] byte uInt8Test = 8;
[Export] byte? uInt8Null = null;
[Export] byte[] uInt8Array = new byte[] { 0, 1, 2, 3, 4, 5 };
[Export] byte?[] uInt8ArrayNull = new byte?[] { 0, null, 2, null, 4, null };
[Public] sbyte int8 = -8;
[Public] sbyte[] int8Array = new sbyte[] { -3, -2, -1, 0, 1, 2 };
[Export] sbyte int8 = -8;
[Export] sbyte[] int8Array = new sbyte[] { -3, -2, -1, 0, 1, 2 };
[Public] char char16 = 'ح';
[Public] char[] char16Array = new char[] { 'م', 'ر', 'ح', 'ب', 'ا' };
[Export] char char16 = 'ح';
[Export] char[] char16Array = new char[] { 'م', 'ر', 'ح', 'ب', 'ا' };
[Public] short int16 = -16;
[Public] short[] int16Array = new short[] { -3, -2, -1, 0, 1, 2 };
[Export] short int16 = -16;
[Export] short[] int16Array = new short[] { -3, -2, -1, 0, 1, 2 };
[Public] ushort uInt16 = 16;
[Public] ushort[] uInt16Array = new ushort[] { 0, 1, 2, 3, 4, 5 };
[Export] ushort uInt16 = 16;
[Export] ushort[] uInt16Array = new ushort[] { 0, 1, 2, 3, 4, 5 };
[Public] int int32Prop = -32;
[Public] int[] int32Array = new int[] { -3, -2, -1, 0, 1, 2 };
[Export] int int32Prop = -32;
[Export] int[] int32Array = new int[] { -3, -2, -1, 0, 1, 2 };
[Public] uint uInt32 = 32;
[Public] uint[] uInt32Array = new uint[] { 0, 1, 2, 3, 4, 5 };
[Export] uint uInt32 = 32;
[Export] uint[] uInt32Array = new uint[] { 0, 1, 2, 3, 4, 5 };
[Public] long int64 = 323232323232;
[Public] long[] int64Array = new long[] { -3, -2, -1, 0, 1, 2 };
[Export] long int64 = 323232323232;
[Export] long[] int64Array = new long[] { -3, -2, -1, 0, 1, 2 };
[Public] ulong uInt64;
[Public] ulong[] uInt64Array = new ulong[] { 0, 1, 2, 3, 4, 5 };
[Export] ulong uInt64;
[Export] ulong[] uInt64Array = new ulong[] { 0, 1, 2, 3, 4, 5 };
[Public] float float32 = 32.32f;
[Public] float[] float32Array = new float[] { -3.3f, -2.2f, -1.1f, 0, 1.1f, 2.2f };
[Export] float float32 = 32.32f;
[Export] float[] float32Array = new float[] { -3.3f, -2.2f, -1.1f, 0, 1.1f, 2.2f };
[Public] double float64 = 32.323232;
[Public] double[] float64Array = new double[] { -3.3, -2.2, -1.1, 0, 1.1, 2.2 };
[Export] double float64 = 32.323232;
[Export] double[] float64Array = new double[] { -3.3, -2.2, -1.1, 0, 1.1, 2.2 };
[Public] decimal float128 = 3232.323232323232m;
[Public] decimal[] float128Array = new decimal[] { -3.3m, -2.2m, -1.1m, 0, 1.1m, 2.2m };
[Export] decimal float128 = 3232.323232323232m;
[Export] decimal[] float128Array = new decimal[] { -3.3m, -2.2m, -1.1m, 0, 1.1m, 2.2m };
[Public("Text")] string stringTest = "Hello World";
[Public] string[] stringArray = new string[] { "Hello", "World" };
[Export("Text")] string stringTest = "Hello World";
[Export] string[] stringArray = new string[] { "Hello", "World" };
[Public] DateTime time = DateTime.Now;
[Export] DateTime time = DateTime.Now;
[Public]
[Export]
Map<string, object> stringMap = new Map<string, object>()
{
["int"] = 33,
["string"] = "Hello World"
};
[Public]
[Export]
Map<int, string> intStringMap = new()
{
[4] = "Abcd",
@ -99,11 +99,11 @@ public partial class MyService
};
[Public("Object")] object objectTest = "object";
[Export("Object")] object objectTest = "object";
[Public] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
[Export] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
[Public]
[Export]
public DistributedPropertyContext<int> PropertyContext
{
get => new DistributedPropertyContext<int>((sender) => sender.RemoteEndPoint.Port);
@ -113,38 +113,38 @@ public partial class MyService
}
}
[Public] public SizeEnum Enum => SizeEnum.Medium;
[Export] public SizeEnum Enum => SizeEnum.Medium;
[Public] public MyRecord Record => new MyRecord() { Id = 33, Name = "Test", Score = 99.33 };
[Export] public MyRecord Record => new MyRecord() { Id = 33, Name = "Test", Score = 99.33 };
[Public] public List<int> IntList => new List<int>() { 1, 2, 3, 4, 5 };
[Export] public List<int> IntList => new List<int>() { 1, 2, 3, 4, 5 };
[Public] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
[Public] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
[Export] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
[Export] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
[Public] public MyResource[] myResources;
[Export] public MyResource[] myResources;
[Public] public MyResource Resource { get; set; }
[Public] public MyChildResource ChildResource { get; set; }
[Export] public MyResource Resource { get; set; }
[Export] public MyChildResource ChildResource { get; set; }
[Public] public MyChildRecord ChildRecord { get; set; } = new MyChildRecord() { ChildName = "Child", Id = 12, Name = "Parent", Score = 12.2 };
[Export] public MyChildRecord ChildRecord { get; set; } = new MyChildRecord() { ChildName = "Child", Id = 12, Name = "Parent", Score = 12.2 };
[Public] public IResource[] Resources { get; set; }
[Export] public IResource[] Resources { get; set; }
[Public]
[Export]
public void Void() =>
Console.WriteLine("Void()");
[Public]
[Export]
public void InvokeEvents(string msg)
{
StringEvent?.Invoke(msg);
ArrayEvent?.Invoke(new object[] { DateTime.UtcNow, "Event", msg });
}
[Public]
[Export]
public double Optional(object a1, int a2, string a3 = "Hello", string a4 = "World")
{
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
@ -152,7 +152,7 @@ public partial class MyService
}
[Public]
[Export]
public AsyncReply<List<Map<int, string?>?>> AsyncHello()
{
var rt = new List<Map<int, string?>?>();
@ -160,32 +160,32 @@ public partial class MyService
return new AsyncReply<List<Map<int, string?>?>>(rt);
}
[Public]
[Export]
public void Connection(object a1, int a2, DistributedConnection a3) =>
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
[Public]
[Export]
public void ConnectionOptional(object a1, int a2, string a3 = "sss", DistributedConnection a4 = null) =>
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
[Public]
[Export]
public (int, string) GetTuple2(int a1, string a2) => (a1, a2);
[Public]
[Export]
public (int, string, double) GetTuple3(int a1, string a2, double a3) => (a1, a2, a3);
[Public]
[Export]
public (int, string, double, bool) GetTuple4(int a1, string a2, double a3, bool a4) => (a1, a2, a3, a4);
[Public]
[Export]
public MyRecord SendRecord(MyRecord record)
{
Console.WriteLine(record.ToString());
return record;
}
[Public] public const double PI = Math.PI;
[Export] public const double PI = Math.PI;
[Public] public MyService Me => this;
[Export] public MyService Me => this;
}

View File

@ -45,7 +45,8 @@ using System.Collections.Generic;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using Esiur.Security.Cryptography;
namespace Test
{
@ -53,6 +54,19 @@ namespace Test
{
static async Task Main(string[] args)
{
var a = new ECDH();
var b = new ECDH();
var apk = a.GetPublicKey();
var bpk = b.GetPublicKey();
var ska = a.ComputeSharedKey(bpk);
var skb = b.ComputeSharedKey(apk);
Console.WriteLine(ska.ToHex());
Console.WriteLine(skb.ToHex());
// Create stores to keep objects.
var system = await Warehouse.Put("sys", new MemoryStore());
var server = await Warehouse.Put("sys/server", new DistributedServer());

View File

@ -2,10 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Esiur.Generator\Esiur.Security.Cryptography.csproj" />
<ProjectReference Include="..\Esiur\Esiur.csproj" OutputItemType="Analyzer" />
</ItemGroup>