работает при разделенной абстракции и реализации

This commit is contained in:
2025-02-05 18:04:35 +03:00
parent 47c67a22af
commit d780d0ea0b
14 changed files with 79 additions and 64 deletions
+13
View File
@@ -0,0 +1,13 @@
using System.Text;
using Example.Shared;
namespace Example.Backend;
public class Page : IPage
{
public string Text;
public byte[] GetData()
{
return Encoding.UTF8.GetBytes(Text);
}
}
+19
View File
@@ -0,0 +1,19 @@
using Example.Shared;
using mROA.Implementation;
namespace Example.Backend;
public class Printer : IPrinter
{
public string Name;
public string GetName()
{
return Name;
}
public TransmittedSharedObject<IPage> Print(string text)
{
return new Page {Text = text};
}
}
+14
View File
@@ -0,0 +1,14 @@
using Example.Backend;
using Example.Shared;
using mROA.Implementation;
namespace Example.Backend;
[SharedObjectSingleton]
public class PrinterFactory : IPrinterFactory
{
public TransmittedSharedObject<IPrinter> Create(string printerName)
{
return new Printer(){Name = printerName};
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
using System.Net;
using Example.Shared;
using Example.Backend;
using mROA.Codegen;
using mROA.Implementation;
using mROA.Implementation.Bootstrap;
@@ -10,7 +10,7 @@ bootstrap.UseJsonSerialisation();
bootstrap.UseNetworkGateway(new IPEndPoint(IPAddress.Loopback, 4567));
bootstrap.UseStreamInteraction();
bootstrap.UseBasicExecution();
bootstrap.UseCollectableContextRepository(typeof(IPrinterFactory).Assembly);
bootstrap.UseCollectableContextRepository(typeof(PrinterFactory).Assembly);
bootstrap.SetupMethodsRepository(new CoCodegenMethodRepository());
bootstrap.Build();