From 56759ccd2e82d5cd6578928b61c4c0abfb4942b5 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Fri, 14 Feb 2025 23:14:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=82=D0=BE=20=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=82=D0=BE=20=D0=BD=D0=B5=D0=B2=D0=B5=D1=80=D0=BE=D1=8F?= =?UTF-8?q?=D1=82=D0=BD=D1=8B=D0=B9=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D0=B5=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D1=8F=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Example.Backend/PrinterFactory.cs | 4 ++++ Example.Frontend/Program.cs | 10 ++++++---- mROA.Codegen/mROA.Codegen.csproj | 2 +- mROA.Codegen/mROASourceGenerator.cs | 3 ++- mROA/Implementation/Backend/BasicExecutionModule.cs | 1 + mROA/Implementation/Backend/JsonSerialisationModule.cs | 5 +++-- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Example.Backend/PrinterFactory.cs b/Example.Backend/PrinterFactory.cs index c04470d..59e12cd 100644 --- a/Example.Backend/PrinterFactory.cs +++ b/Example.Backend/PrinterFactory.cs @@ -12,21 +12,25 @@ public class PrinterFactory : IPrinterFactory public SharedObject Create(string printerName) { + Console.WriteLine("Creating printer"); return new Printer { Name = printerName }; } public void Register(SharedObject printer) { + Console.WriteLine("Registered printer"); _printers.Add(printer.Value); } public SharedObject GetPrinterByName(string printerName) { + Console.WriteLine("Getting printer"); return new SharedObject(_printers.Find(i => i.GetName() == printerName)!); } public string[] CollectAllNames() { + Console.WriteLine("Collecting all printers"); return _printers.Select(i => i.GetName()).ToArray(); } } \ No newline at end of file diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 69e91b8..34b7efe 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -28,13 +28,15 @@ var factory = context.GetSingleObject(typeof(IPrinterFactory)) as IPrinterFactor var printer = factory.Create("Test"); -// var name = printer.Value.GetName(); -// Console.WriteLine("Printer name : {0}", name); +var name = printer.Value.GetName(); +Console.WriteLine("Printer name : {0}", name); +Console.WriteLine("Registered printer"); factory.Register(new SharedObject(new ClientBasedPrinter())); - -// var names = factory.CollectAllNames(); +Console.WriteLine("Collecting all printers"); +var names = factory.CollectAllNames(); Console.ReadLine(); + // var page = await printer.Value.Print("Test Page", new CancellationToken()); // var data = page.Value.GetData(); // Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data)); diff --git a/mROA.Codegen/mROA.Codegen.csproj b/mROA.Codegen/mROA.Codegen.csproj index 55fe8a0..0b8cdea 100644 --- a/mROA.Codegen/mROA.Codegen.csproj +++ b/mROA.Codegen/mROA.Codegen.csproj @@ -17,7 +17,7 @@ https://github.com/YaslePoy/mROA git True - 1.0.7 + 1.2.0 diff --git a/mROA.Codegen/mROASourceGenerator.cs b/mROA.Codegen/mROASourceGenerator.cs index 0d7fe19..b3122de 100644 --- a/mROA.Codegen/mROASourceGenerator.cs +++ b/mROA.Codegen/mROASourceGenerator.cs @@ -141,7 +141,8 @@ namespace {Namespace} sb.AppendLine( $"\t\tvar defaultCallRequestCodegen = new DefaultCallRequest {{ CommandId = {index}, ObjectId = id }};"); } - + + sb.AppendLine("\t\tSystem.Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(defaultCallRequestCodegen));"); //Post created request sb.AppendLine("\t\tserialisationModule.PostCallRequest(defaultCallRequestCodegen);"); diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs index f8b2fff..274b872 100644 --- a/mROA/Implementation/Backend/BasicExecutionModule.cs +++ b/mROA/Implementation/Backend/BasicExecutionModule.cs @@ -14,6 +14,7 @@ public class BasicExecutionModule : IExecuteModule public ICommandExecution Execute(ICallRequest command, IContextRepository _contextRepo) { + Console.WriteLine($"Executing command: {command.CommandId}"); if (_methodRepo is null) throw new NullReferenceException("Method repository was not defined"); diff --git a/mROA/Implementation/Backend/JsonSerialisationModule.cs b/mROA/Implementation/Backend/JsonSerialisationModule.cs index ec9cd52..ea873c2 100644 --- a/mROA/Implementation/Backend/JsonSerialisationModule.cs +++ b/mROA/Implementation/Backend/JsonSerialisationModule.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using System.Text; +using System.Text.Json; using mROA.Abstract; namespace mROA.Implementation.Backend; @@ -15,7 +16,7 @@ public class JsonSerialisationModule : ISerialisationModule var ownership = TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository ?? throw new Exception("Set ownership repository type is incorrect"); ownership.RegisterOwnership(clientId); NetworkMessage input = JsonSerializer.Deserialize(message)!; - + Console.WriteLine(Encoding.Default.GetString(input.Data)); if (input.SchemaId == MessageType.CallRequest) { var command = JsonSerializer.Deserialize(input.Data)!;