работает при разделенной абстракции и реализации
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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};
|
||||
}
|
||||
}
|
||||
@@ -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};
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user