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

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 System.Net;
using Example.Shared; using Example.Backend;
using mROA.Codegen; using mROA.Codegen;
using mROA.Implementation; using mROA.Implementation;
using mROA.Implementation.Bootstrap; using mROA.Implementation.Bootstrap;
@@ -10,7 +10,7 @@ bootstrap.UseJsonSerialisation();
bootstrap.UseNetworkGateway(new IPEndPoint(IPAddress.Loopback, 4567)); bootstrap.UseNetworkGateway(new IPEndPoint(IPAddress.Loopback, 4567));
bootstrap.UseStreamInteraction(); bootstrap.UseStreamInteraction();
bootstrap.UseBasicExecution(); bootstrap.UseBasicExecution();
bootstrap.UseCollectableContextRepository(typeof(IPrinterFactory).Assembly); bootstrap.UseCollectableContextRepository(typeof(PrinterFactory).Assembly);
bootstrap.SetupMethodsRepository(new CoCodegenMethodRepository()); bootstrap.SetupMethodsRepository(new CoCodegenMethodRepository());
bootstrap.Build(); bootstrap.Build();
-3
View File
@@ -11,7 +11,4 @@
<ProjectReference Include="..\Example.Shared\Example.Shared.csproj" /> <ProjectReference Include="..\Example.Shared\Example.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
</ItemGroup>
</Project> </Project>
+2 -3
View File
@@ -7,9 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj" <ProjectReference Include="..\mROA.Codegen\mROA.Codegen.csproj" OutputItemType="Analyzer"
OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\mROA\mROA.csproj" /> <ProjectReference Include="..\mROA\mROA.csproj" />
</ItemGroup> </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; using mROA.Implementation;
namespace Example.Shared; namespace Example.Shared;
@@ -7,52 +6,4 @@ namespace Example.Shared;
public interface IPrinterFactory public interface IPrinterFactory
{ {
TransmittedSharedObject<IPrinter> Create(string printerName); 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);
}
} }
+1 -1
View File
@@ -3,7 +3,7 @@
"profiles": { "profiles": {
"DebugRoslynSourceGenerator": { "DebugRoslynSourceGenerator": {
"commandName": "DebugRoslynComponent", "commandName": "DebugRoslynComponent",
"targetProject": "../Example.Shared/Example.Shared.csproj" "targetProject": "../Example.Backend/Example.Backend.csproj"
} }
} }
} }
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Codegen")] [assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Codegen")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ed4e97e40f713de9270db709d05167c00f9c565b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47c67a22afbe9bd7560c8687b1d56893fcdd2fad")]
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Codegen")] [assembly: System.Reflection.AssemblyProductAttribute("mROA.Codegen")]
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Codegen")] [assembly: System.Reflection.AssemblyTitleAttribute("mROA.Codegen")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")] [assembly: System.Reflection.AssemblyCompanyAttribute("mROA.Test")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ed4e97e40f713de9270db709d05167c00f9c565b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47c67a22afbe9bd7560c8687b1d56893fcdd2fad")]
[assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")] [assembly: System.Reflection.AssemblyProductAttribute("mROA.Test")]
[assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")] [assembly: System.Reflection.AssemblyTitleAttribute("mROA.Test")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
+1
View File
@@ -4,6 +4,7 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Title>mROA</Title>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
+5 -4
View File
@@ -1,9 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// the code is regenerated. // повторной генерации кода.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -13,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("mROA")] [assembly: System.Reflection.AssemblyCompanyAttribute("mROA")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ed4e97e40f713de9270db709d05167c00f9c565b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47c67a22afbe9bd7560c8687b1d56893fcdd2fad")]
[assembly: System.Reflection.AssemblyProductAttribute("mROA")] [assembly: System.Reflection.AssemblyProductAttribute("mROA")]
[assembly: System.Reflection.AssemblyTitleAttribute("mROA")] [assembly: System.Reflection.AssemblyTitleAttribute("mROA")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]