Практически доделанный кодген, но не работает демка

This commit is contained in:
2025-03-10 00:00:24 +03:00
parent e0088ea22c
commit 0dbc065d9e
18 changed files with 248 additions and 149 deletions
-1
View File
@@ -1,4 +1,3 @@
using System;
using Example.Shared;
namespace Example.Backend
+14 -6
View File
@@ -8,27 +8,31 @@ namespace Example.Backend
{
public class PagesList : RemoteObjectBase, IPagesList
{
public PagesList(int id, IRepresentationModule representationModule) : base(id, representationModule)
{
}
public IReadOnlyList<IPage> Collection { get; }
public Example.Shared.IPage this[int index]
public IPage this[int index]
{
get => GetResultAsync<Example.Shared.IPage>(3, new object[] { index }).GetAwaiter().GetResult();
get => GetResultAsync<IPage>(3, new object[] { index }).GetAwaiter().GetResult();
set => CallAsync(5, new object[] { index, value }).Wait();
}
public IPage Get(int index)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public void Add(IPage item)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public void Remove(int index, IPage item)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public event Action<IPage>? OnAdd;
@@ -39,7 +43,11 @@ namespace Example.Backend
// TODO release managed resources here
}
public PagesList(int id, IRepresentationModule representationModule) : base(id, representationModule)
public void OnAddExternal(IPage p0)
{
}
public void OnRemoveExternal(IPage p0)
{
}
}
+9 -4
View File
@@ -10,6 +10,10 @@ namespace Example.Backend
{
public string Name;
public void OnPrintExternal(IPage p0, RequestContext p1)
{
}
public double Resource { get; set; } = 100d;
public string GetName()
@@ -17,22 +21,23 @@ namespace Example.Backend
return Name;
}
public async Task<IPage> Print(string text, bool some, CancellationToken cancellationToken = default)
public async Task<IPage> Print(string text, bool some, RequestContext context,
CancellationToken cancellationToken = default)
{
// throw new Exception("The method or operation is not implemented.");
var page = new Page { Text = text };
OnPrint?.Invoke(page);
Console.WriteLine($"Request id : :{context.RequestId}");
OnPrint?.Invoke(page, context);
Resource /= 1.5;
return page;
}
public event Action<IPage>? OnPrint;
public event Action<IPage, RequestContext>? OnPrint;
public void Dispose()
{
Console.WriteLine(
"Dispose printer with name {0}, Dispose works, Dispose works, Dispose works, Dispose works,", Name);
}
}
}
-1
View File
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Example.Shared;
using mROA.Implementation;
using mROA.Implementation.Attributes;
namespace Example.Backend
+1 -3
View File
@@ -1,6 +1,5 @@
using System.Net;
using Example.Backend;
using Example.Shared;
using mROA.Abstract;
using mROA.Cbor;
using mROA.Codegen;
@@ -38,7 +37,7 @@ class Program
new IInjectableModule[] { builder.GetModule<ISerializationToolkit>()! },
typeof(RepresentationModule)));
builder.Modules.Add(new CancellationRepository());
builder.Build();
new RemoteTypeBinder();
@@ -49,6 +48,5 @@ class Program
var gateway = builder.GetModule<IGatewayModule>();
gateway.Run();
}
}