Добавление препроцессора для очистки консоли
This commit is contained in:
@@ -10,6 +10,10 @@
|
|||||||
<LangVersion>9</LangVersion>
|
<LangVersion>9</LangVersion>
|
||||||
</PropertyGroup>
|
</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>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Example.Shared;
|
using Example.Shared;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using BenchmarkDotNet.Running;
|
|
||||||
|
|
||||||
namespace mROA.Benchmark
|
namespace mROA.Benchmark
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
|||||||
using System.Formats.Cbor;
|
using System.Formats.Cbor;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
|
||||||
using mROA.Abstract;
|
using mROA.Abstract;
|
||||||
using mROA.Implementation;
|
using mROA.Implementation;
|
||||||
using mROA.Implementation.Attributes;
|
using mROA.Implementation.Attributes;
|
||||||
|
|||||||
@@ -27,18 +27,18 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
|
||||||
using mROA.Implementation;
|
using mROA.Implementation;
|
||||||
using mROA.Implementation.CommandExecution;
|
using mROA.Implementation.CommandExecution;
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ namespace mROA.Implementation.Backend
|
|||||||
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
|
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
|
||||||
IRepresentationModule representationModule)
|
IRepresentationModule representationModule)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine(command.GetType().Name);
|
Console.WriteLine(command.GetType().Name);
|
||||||
|
#endif
|
||||||
if (_cancellationRepo is null)
|
if (_cancellationRepo is null)
|
||||||
throw new NullReferenceException("Method repository was not defined");
|
throw new NullReferenceException("Method repository was not defined");
|
||||||
|
|
||||||
@@ -34,7 +35,9 @@ namespace mROA.Implementation.Backend
|
|||||||
|
|
||||||
if (command is CancelRequest)
|
if (command is CancelRequest)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Final cancelling request");
|
Console.WriteLine("Final cancelling request");
|
||||||
|
#endif
|
||||||
var cts = _cancellationRepo.GetCancellation(command.Id);
|
var cts = _cancellationRepo.GetCancellation(command.Id);
|
||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
_cancellationRepo.FreeCancelation(command.Id);
|
_cancellationRepo.FreeCancelation(command.Id);
|
||||||
@@ -68,7 +71,9 @@ namespace mROA.Implementation.Backend
|
|||||||
var result = Execute(currentCommand, context, parameter, command);
|
var result = Execute(currentCommand, context, parameter, command);
|
||||||
if (command.CommandId == -1)
|
if (command.CommandId == -1)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Disposing object");
|
Console.WriteLine("Disposing object");
|
||||||
|
#endif
|
||||||
contextRepository.ClearObject(command.ObjectId);
|
contextRepository.ClearObject(command.ObjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +123,9 @@ namespace mROA.Implementation.Backend
|
|||||||
var tokenSource = new CancellationTokenSource();
|
var tokenSource = new CancellationTokenSource();
|
||||||
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
|
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
|
||||||
var token = tokenSource.Token;
|
var token = tokenSource.Token;
|
||||||
|
#if TRACE
|
||||||
token.Register(() => Console.WriteLine($"Cancellation requested check {command.Id}"));
|
token.Register(() => Console.WriteLine($"Cancellation requested check {command.Id}"));
|
||||||
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var finalParameter = parameter is null
|
var finalParameter = parameter is null
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ namespace mROA.Implementation.Frontend
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Waiting for request...");
|
Console.WriteLine("Waiting for request...");
|
||||||
|
#endif
|
||||||
var tokenSource = new CancellationTokenSource();
|
var tokenSource = new CancellationTokenSource();
|
||||||
var token = tokenSource.Token;
|
var token = tokenSource.Token;
|
||||||
var defaultRequest =
|
var defaultRequest =
|
||||||
@@ -74,12 +76,15 @@ namespace mROA.Implementation.Frontend
|
|||||||
messageType: MessageType.CancelRequest, token: token);
|
messageType: MessageType.CancelRequest, token: token);
|
||||||
|
|
||||||
Task.WaitAny(defaultRequest, cancelRequest);
|
Task.WaitAny(defaultRequest, cancelRequest);
|
||||||
|
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Request received");
|
Console.WriteLine("Request received");
|
||||||
|
#endif
|
||||||
if (cancelRequest.IsCompleted)
|
if (cancelRequest.IsCompleted)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Cancelling request");
|
Console.WriteLine("Cancelling request");
|
||||||
|
#endif
|
||||||
var req = cancelRequest.Result;
|
var req = cancelRequest.Result;
|
||||||
tokenSource.Cancel();
|
tokenSource.Cancel();
|
||||||
_executeModule.Execute(req, _contextRepository, _representationModule);
|
_executeModule.Execute(req, _contextRepository, _representationModule);
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ namespace mROA.Implementation
|
|||||||
// Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len]));
|
// Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len]));
|
||||||
|
|
||||||
var message = _serialization.Deserialize<NetworkMessage>(localSpan.Span);
|
var message = _serialization.Deserialize<NetworkMessage>(localSpan.Span);
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}");
|
Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}");
|
||||||
|
#endif
|
||||||
_messageBuffer.Add(message);
|
_messageBuffer.Add(message);
|
||||||
_currentReceiving = Task.Run(async () => await GetNextMessage());
|
_currentReceiving = Task.Run(async () => await GetNextMessage());
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ namespace mROA.Implementation
|
|||||||
|
|
||||||
cancellationToken.Register(async () =>
|
cancellationToken.Register(async () =>
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Cancelling task");
|
Console.WriteLine("Cancelling task");
|
||||||
|
#endif
|
||||||
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
|
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
|
||||||
new CancelRequest
|
new CancelRequest
|
||||||
{
|
{
|
||||||
@@ -92,7 +94,9 @@ namespace mROA.Implementation
|
|||||||
|
|
||||||
cancellationToken.Register(async () =>
|
cancellationToken.Register(async () =>
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Cancelling task");
|
Console.WriteLine("Cancelling task");
|
||||||
|
#endif
|
||||||
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
|
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
|
||||||
new CancelRequest
|
new CancelRequest
|
||||||
{
|
{
|
||||||
@@ -106,8 +110,9 @@ namespace mROA.Implementation
|
|||||||
errorResponse, successResponse
|
errorResponse, successResponse
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
|
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine($"Handling message");
|
Console.WriteLine($"Handling message");
|
||||||
|
#endif
|
||||||
if (successResponse.IsCompletedSuccessfully)
|
if (successResponse.IsCompletedSuccessfully)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ namespace mROA.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized")).ConnectionId;
|
public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized"))
|
||||||
|
.ConnectionId;
|
||||||
|
|
||||||
public async Task<T> GetMessageAsync<T>(Guid? requestId, MessageType? messageType, CancellationToken token = default)
|
public async Task<T> GetMessageAsync<T>(Guid? requestId, MessageType? messageType,
|
||||||
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (_serialization == null)
|
if (_serialization == null)
|
||||||
throw new NullReferenceException("Serialization toolkit is not initialized");
|
throw new NullReferenceException("Serialization toolkit is not initialized");
|
||||||
@@ -43,25 +45,26 @@ namespace mROA.Implementation
|
|||||||
return _serialization.Deserialize<T>(rawMessage)!;
|
return _serialization.Deserialize<T>(rawMessage)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<byte[]> GetRawMessage(Guid? requestId = null, MessageType? messageType = null, CancellationToken token = default)
|
public async Task<byte[]> GetRawMessage(Guid? requestId = null, MessageType? messageType = null,
|
||||||
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (_interaction == null)
|
if (_interaction == null)
|
||||||
throw new NullReferenceException("Interaction toolkit is not initialized");
|
throw new NullReferenceException("Interaction toolkit is not initialized");
|
||||||
|
|
||||||
var fromBuffer =
|
var fromBuffer =
|
||||||
_interaction.FirstByFilter(message =>
|
_interaction.FirstByFilter(message =>
|
||||||
(requestId is null || message.Id == requestId) &&
|
(requestId is null || message.Id == requestId) &&
|
||||||
(messageType is null || message.SchemaId == messageType));
|
(messageType is null || message.SchemaId == messageType));
|
||||||
|
|
||||||
if (fromBuffer == null)
|
if (fromBuffer == null)
|
||||||
{
|
{
|
||||||
while (token.IsCancellationRequested == false)
|
while (token.IsCancellationRequested == false)
|
||||||
{
|
{
|
||||||
var message = await _interaction.GetNextMessageReceiving();
|
var message = await _interaction.GetNextMessageReceiving();
|
||||||
if ((requestId is not null && message.Id != requestId) ||
|
if ((requestId is not null && message.Id != requestId) ||
|
||||||
(messageType is not null && message.SchemaId != messageType))
|
(messageType is not null && message.SchemaId != messageType))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_interaction.HandleMessage(message);
|
_interaction.HandleMessage(message);
|
||||||
return message.Data;
|
return message.Data;
|
||||||
}
|
}
|
||||||
@@ -82,8 +85,9 @@ namespace mROA.Implementation
|
|||||||
throw new NullReferenceException("Interaction toolkit is not initialized");
|
throw new NullReferenceException("Interaction toolkit is not initialized");
|
||||||
if (_serialization == null)
|
if (_serialization == null)
|
||||||
throw new NullReferenceException("Serialization toolkit is not initialized");
|
throw new NullReferenceException("Serialization toolkit is not initialized");
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine($"Posting message: {id} - {messageType}");
|
Console.WriteLine($"Posting message: {id} - {messageType}");
|
||||||
|
#endif
|
||||||
|
|
||||||
var serialized = _serialization.Serialize(payload, payloadType);
|
var serialized = _serialization.Serialize(payload, payloadType);
|
||||||
await _interaction.PostMessage(new NetworkMessage
|
await _interaction.PostMessage(new NetworkMessage
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ namespace mROA.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore] public T Value { get; private set; }
|
[JsonIgnore]
|
||||||
|
public T Value { get; private set; }
|
||||||
|
|
||||||
// ReSharper disable once MemberCanBePrivate.Global
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
// ReSharper disable once UnusedMember.Global
|
// ReSharper disable once UnusedMember.Global
|
||||||
@@ -106,6 +107,7 @@ namespace mROA.Implementation
|
|||||||
public static implicit operator SharedObject<T>(T value) =>
|
public static implicit operator SharedObject<T>(T value) =>
|
||||||
new(value);
|
new(value);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public IEndPointContext EndPointContext { get; set; } = new EndPointContext
|
public IEndPointContext EndPointContext { get; set; } = new EndPointContext
|
||||||
{
|
{
|
||||||
RealRepository = TransmissionConfig.RealContextRepository,
|
RealRepository = TransmissionConfig.RealContextRepository,
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
using global::System;
|
using System.IO;
|
||||||
using global::System.IO;
|
using System.Threading;
|
||||||
using global::System.Threading;
|
using System.Threading.Tasks;
|
||||||
using global::System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace mROA
|
namespace mROA
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,16 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageTags>RPC</PackageTags>
|
<PackageTags>RPC</PackageTags>
|
||||||
<LangVersion>9</LangVersion>
|
<LangVersion>9</LangVersion>
|
||||||
|
<Configurations>Debug;Release</Configurations>
|
||||||
|
<Platforms>AnyCPU</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<DefineConstants />
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<DefineConstants />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user