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

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
+2 -3
View File
@@ -7,9 +7,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj" OutputItemType="Analyzer"
ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\mROA\mROA.csproj" />
</ItemGroup>
+9
View File
@@ -0,0 +1,9 @@
using mROA.Implementation;
namespace Example.Shared;
[SharedObjectInterface]
public interface IPage
{
byte[] GetData();
}
+11
View File
@@ -0,0 +1,11 @@
using mROA.Implementation;
namespace Example.Shared;
[SharedObjectInterface]
public interface IPrinter
{
string GetName();
TransmittedSharedObject<IPage> Print(string text);
}
-49
View File
@@ -1,4 +1,3 @@
using System.Text;
using mROA.Implementation;
namespace Example.Shared;
@@ -7,52 +6,4 @@ namespace Example.Shared;
public interface IPrinterFactory
{
TransmittedSharedObject<IPrinter> Create(string printerName);
}
[SharedObjectSingleton]
public class PrinterFactory : IPrinterFactory
{
public TransmittedSharedObject<IPrinter> Create(string printerName)
{
return new Printer(){Name = printerName};
}
}
[SharedObjectInterface]
public interface IPrinter
{
string GetName();
TransmittedSharedObject<IPage> Print(string text);
}
public class Printer : IPrinter
{
public string Name;
public string GetName()
{
return Name;
}
public TransmittedSharedObject<IPage> Print(string text)
{
return new Page {Text = text};
}
}
[SharedObjectInterface]
public interface IPage
{
byte[] GetData();
}
public class Page : IPage
{
public string Text;
public byte[] GetData()
{
return Encoding.UTF8.GetBytes(Text);
}
}