cbor works

This commit is contained in:
2025-02-27 08:40:22 +03:00
parent 46732da780
commit 5718f9c313
10 changed files with 45 additions and 48 deletions
+4
View File
@@ -14,6 +14,10 @@
<DefineConstants /> <DefineConstants />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Example.Shared\Example.Shared.csproj" /> <ProjectReference Include="..\Example.Shared\Example.Shared.csproj" />
</ItemGroup> </ItemGroup>
+1 -1
View File
@@ -34,7 +34,7 @@ class Program
})); }));
builder.SetupMethodsRepository(new CoCodegenMethodRepository()); builder.SetupMethodsRepository(new CoCodegenMethodRepository());
builder.Modules.Add(new CreativeRepresentationModuleProducer( builder.Modules.Add(new CreativeRepresentationModuleProducer(
new IInjectableModule[] { builder.GetModule<JsonSerializationToolkit>()! }, new IInjectableModule[] { builder.GetModule<CborSerializationToolkit>()! },
typeof(RepresentationModule))); typeof(RepresentationModule)));
builder.Modules.Add(new CancellationRepository()); builder.Modules.Add(new CancellationRepository());
+8
View File
@@ -9,6 +9,14 @@
<LangVersion>9</LangVersion> <LangVersion>9</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Example.Shared\Example.Shared.csproj" /> <ProjectReference Include="..\Example.Shared\Example.Shared.csproj" />
</ItemGroup> </ItemGroup>
+8
View File
@@ -5,6 +5,14 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants />
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\mROA\mROA.csproj" /> <ProjectReference Include="..\mROA\mROA.csproj" />
</ItemGroup> </ItemGroup>
-2
View File
@@ -5,7 +5,5 @@ namespace mROA.Abstract
public interface ICommandExecution public interface ICommandExecution
{ {
Guid Id { get; set; } Guid Id { get; set; }
int ClientId { get; set; }
int CommandId { get; }
} }
} }
@@ -43,8 +43,7 @@ namespace mROA.Implementation.Backend
_cancellationRepo.FreeCancelation(command.Id); _cancellationRepo.FreeCancelation(command.Id);
return new FinalCommandExecution return new FinalCommandExecution
{ {
Id = command.Id, Id = command.Id
CommandId = command.CommandId
}; };
} }
@@ -84,8 +83,6 @@ namespace mROA.Implementation.Backend
Console.WriteLine(e); Console.WriteLine(e);
throw; throw;
} }
} }
private static ICommandExecution Execute(MethodInfo currentCommand, object context, object? parameter, private static ICommandExecution Execute(MethodInfo currentCommand, object context, object? parameter,
@@ -99,18 +96,25 @@ namespace mROA.Implementation.Backend
{ parameter }; { parameter };
var finalResult = currentCommand.Invoke(context, finalParameter); var finalResult = currentCommand.Invoke(context, finalParameter);
return new TypedFinalCommandExecution if (currentCommand.ReturnType.Name == "Void")
{ {
CommandId = command.CommandId, Result = finalResult, return new FinalCommandExecution
Id = command.Id, {
Type = currentCommand.ReturnType Id = command.Id
};
}
return new FinalCommandExecution<object>
{
Result = finalResult,
Id = command.Id
}; };
} }
catch (Exception e) catch (Exception e)
{ {
return new ExceptionCommandExecution return new ExceptionCommandExecution
{ {
Id = command.Id, CommandId = command.CommandId, Id = command.Id,
Exception = e.ToString() Exception = e.ToString()
}; };
} }
@@ -142,8 +146,7 @@ namespace mROA.Implementation.Backend
var payload = new FinalCommandExecution var payload = new FinalCommandExecution
{ {
Id = command.Id, Id = command.Id
CommandId = command.CommandId
}; };
_cancellationRepo.FreeCancelation(command.Id); _cancellationRepo.FreeCancelation(command.Id);
@@ -157,14 +160,14 @@ namespace mROA.Implementation.Backend
return new AsyncCommandExecution return new AsyncCommandExecution
{ {
Id = command.Id, CommandId = command.CommandId Id = command.Id
}; };
} }
catch (Exception e) catch (Exception e)
{ {
return new ExceptionCommandExecution return new ExceptionCommandExecution
{ {
Id = command.Id, CommandId = command.CommandId, Id = command.Id,
Exception = e.ToString() Exception = e.ToString()
}; };
} }
@@ -190,12 +193,10 @@ namespace mROA.Implementation.Backend
result.ContinueWith(t => result.ContinueWith(t =>
{ {
var finalResult = t.GetType().GetProperty("Result")?.GetValue(t); var finalResult = t.GetType().GetProperty("Result")?.GetValue(t);
var payload = new TypedFinalCommandExecution var payload = new FinalCommandExecution<object>
{ {
Id = command.Id, Id = command.Id,
Result = finalResult, Result = finalResult
CommandId = command.CommandId,
Type = finalResult?.GetType()
}; };
_cancellationRepo.FreeCancelation(command.Id); _cancellationRepo.FreeCancelation(command.Id);
@@ -208,14 +209,14 @@ namespace mROA.Implementation.Backend
return new AsyncCommandExecution return new AsyncCommandExecution
{ {
Id = command.Id, CommandId = command.CommandId Id = command.Id
}; };
} }
catch (Exception e) catch (Exception e)
{ {
return new ExceptionCommandExecution return new ExceptionCommandExecution
{ {
Id = command.Id, CommandId = command.CommandId, Id = command.Id,
Exception = e.ToString() Exception = e.ToString()
}; };
} }
@@ -6,7 +6,5 @@ namespace mROA.Implementation.CommandExecution
public class AsyncCommandExecution : ICommandExecution public class AsyncCommandExecution : ICommandExecution
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public int ClientId { get; set; }
public int CommandId { get; set; }
} }
} }
@@ -7,8 +7,6 @@ namespace mROA.Implementation.CommandExecution
public class ExceptionCommandExecution : ICommandExecution public class ExceptionCommandExecution : ICommandExecution
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public int ClientId { get; set; }
public int CommandId { get; set; }
public string Exception { get; set; } public string Exception { get; set; }
public RemoteException GetException() public RemoteException GetException()
@@ -1,7 +1,6 @@
using System; using System;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using mROA.Abstract; using mROA.Abstract;
using mROA.Implementation.Attributes;
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
@@ -10,10 +9,6 @@ namespace mROA.Implementation.CommandExecution
public class FinalCommandExecution : ICommandExecution public class FinalCommandExecution : ICommandExecution
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
[SerializationIgnore]
public int ClientId { get; set; }
[SerializationIgnore]
public int CommandId { get; set; }
} }
public class FinalCommandExecution<T> : FinalCommandExecution public class FinalCommandExecution<T> : FinalCommandExecution
@@ -1,13 +0,0 @@
using System;
using System.Text.Json.Serialization;
using mROA.Implementation.Attributes;
namespace mROA.Implementation.CommandExecution
{
public class TypedFinalCommandExecution : FinalCommandExecution<object>
{
[SerializationIgnore]
// ReSharper disable once UnusedAutoPropertyAccessor.Global
public Type? Type { get; set; }
}
}