Merge remote-tracking branch 'origin/Untrusted' into Untrusted
This commit is contained in:
@@ -30,11 +30,11 @@ class Program
|
||||
builder.Modules.Add(new CreativeRepresentationModuleProducer(
|
||||
new IInjectableModule[] { builder.GetModule<IContextualSerializationToolKit>()! },
|
||||
typeof(RepresentationModule)));
|
||||
builder.Modules.Add(new RemoteContextRepository());
|
||||
builder.Modules.Add(new RemoteInstanceRepository());
|
||||
// builder.UseCollectableContextRepository(typeof(PrinterFactory).Assembly);
|
||||
builder.Modules.Add(new MultiClientContextRepository(i =>
|
||||
builder.Modules.Add(new MultiClientInstanceRepository(i =>
|
||||
{
|
||||
var repo = new ContextRepository();
|
||||
var repo = new InstanceRepository();
|
||||
repo.FillSingletons(typeof(PrinterFactory).Assembly);
|
||||
repo.Inject(builder.Modules.OfType<CreativeRepresentationModuleProducer>().First());
|
||||
return repo;
|
||||
|
||||
+18
-16
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,7 +23,7 @@ class Program
|
||||
|
||||
builder.Modules.Add(new CborSerializationToolkit());
|
||||
builder.Modules.Add(new EndPointContext());
|
||||
builder.Modules.Add(new RemoteContextRepository());
|
||||
builder.Modules.Add(new RemoteInstanceRepository());
|
||||
builder.Modules.Add(new ChannelInteractionModule());
|
||||
builder.Modules.Add(new UdpUntrustedInteraction());
|
||||
builder.Modules.Add(new RepresentationModule());
|
||||
@@ -43,7 +43,7 @@ class Program
|
||||
_ = builder.GetModule<RequestExtractor>()!.StartExtraction();
|
||||
_ = builder.GetModule<UdpUntrustedInteraction>().Start(serverEndPoint);
|
||||
Console.WriteLine(builder.GetModule<IEndPointContext>().HostId);
|
||||
var context = builder.GetModule<RemoteContextRepository>();
|
||||
var context = builder.GetModule<RemoteInstanceRepository>();
|
||||
|
||||
var factory =
|
||||
context.GetSingleObject(typeof(IPrinterFactory),
|
||||
@@ -126,23 +126,25 @@ class Program
|
||||
Console.WriteLine($"Token state {cts.Token.IsCancellationRequested}");
|
||||
DemoCheck.TaskCancelation = true;
|
||||
|
||||
const int iterations = 10000;
|
||||
var timer = Stopwatch.StartNew();
|
||||
var x = 0;
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
x = loadSingleton.Next(x);
|
||||
}
|
||||
|
||||
timer.Stop();
|
||||
Console.WriteLine("X is {0}", x);
|
||||
Console.WriteLine("Time : {0}", timer.Elapsed.TotalMilliseconds);
|
||||
Console.WriteLine($"Time per call: {timer.Elapsed.TotalMilliseconds / iterations} ms");
|
||||
|
||||
frontendBridge.Disconnect();
|
||||
|
||||
DemoCheck.Show();
|
||||
Console.ReadKey();
|
||||
|
||||
//
|
||||
// const int iterations = 10000;
|
||||
// var timer = Stopwatch.StartNew();
|
||||
// var x = 0;
|
||||
// for (int i = 0; i < iterations; i++)
|
||||
// {
|
||||
// x = loadSingleton.Next(x);
|
||||
// }
|
||||
//
|
||||
// timer.Stop();
|
||||
// Console.WriteLine("X is {0}", x);
|
||||
// Console.WriteLine("Time : {0}", timer.Elapsed.TotalMilliseconds);
|
||||
// Console.WriteLine($"Time per call: {timer.Elapsed.TotalMilliseconds / iterations} ms");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ namespace mROA.Codegen
|
||||
public sealed class RemoteTypeBinder
|
||||
{
|
||||
static RemoteTypeBinder(){
|
||||
RemoteContextRepository.RemoteTypes = new Dictionary<Type, Type> {
|
||||
RemoteInstanceRepository.RemoteTypes = new Dictionary<Type, Type> {
|
||||
<!I remoteTypePair r sep typesSep><!D typesSep>,
|
||||
<!D>
|
||||
};
|
||||
ContextRepository.EventBinders = new object[] {
|
||||
InstanceRepository.EventBinders = new object[] {
|
||||
<!I eventBinder r sep typesSep>
|
||||
<!T objectBinderTemplate>
|
||||
new EventBinder<<!L type>>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Implementation;
|
||||
@@ -9,7 +8,6 @@ namespace mROA.Abstract
|
||||
public interface IChannelInteractionModule : IInjectableModule, IDisposable
|
||||
{
|
||||
int ConnectionId { get; set; }
|
||||
IEndPointContext Context { get; set; }
|
||||
Channel<NetworkMessageHeader> ReceiveChanel { get; }
|
||||
ChannelReader<NetworkMessageHeader> TrustedPostChanel { get; }
|
||||
ChannelReader<NetworkMessageHeader> UntrustedPostChanel { get; }
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace mROA.Abstract
|
||||
{
|
||||
public interface IContextRepositoryHub
|
||||
{
|
||||
IContextRepository GetRepository(int clientId);
|
||||
IInstanceRepository GetRepository(int clientId);
|
||||
void FreeRepository(int clientId);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
{
|
||||
public interface IEndPointContext : IInjectableModule
|
||||
{
|
||||
IContextRepository RealRepository { get; }
|
||||
IContextRepository RemoteRepository { get; }
|
||||
IInstanceRepository RealRepository { get; }
|
||||
IInstanceRepository RemoteRepository { get; }
|
||||
int HostId { get; set; }
|
||||
int OwnerId { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mROA.Abstract
|
||||
{
|
||||
public interface IExecuteModule : IInjectableModule
|
||||
{
|
||||
ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
|
||||
ICommandExecution Execute(ICallRequest command, IInstanceRepository instanceRepository,
|
||||
IRepresentationModule representationModule, IEndPointContext context);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,8 @@ using mROA.Implementation;
|
||||
|
||||
namespace mROA.Abstract
|
||||
{
|
||||
public interface IContextRepository : IInjectableModule
|
||||
public interface IInstanceRepository : IInjectableModule
|
||||
{
|
||||
int HostId { get; set; }
|
||||
int ResisterObject<T>(object o, IEndPointContext context);
|
||||
void ClearObject(ComplexObjectIdentifier id, IEndPointContext context);
|
||||
T GetObject<T>(ComplexObjectIdentifier id, IEndPointContext context);
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace mROA.Abstract
|
||||
namespace mROA.Abstract
|
||||
{
|
||||
// public interface IContextualSerializationToolKit : IInjectableModule
|
||||
// {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mROA.Abstract
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace mROA.Implementation.Backend
|
||||
|
||||
public static void UseCollectableContextRepository(this FullMixBuilder builder, params Assembly[] assemblies)
|
||||
{
|
||||
var repo = new ContextRepository();
|
||||
var repo = new InstanceRepository();
|
||||
repo.FillSingletons(assemblies);
|
||||
builder.Modules.Add(repo);
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace mROA.Implementation.Backend
|
||||
}
|
||||
}
|
||||
|
||||
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
|
||||
public ICommandExecution Execute(ICallRequest command, IInstanceRepository instanceRepository,
|
||||
IRepresentationModule representationModule, IEndPointContext endPointContext)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
ThrowIfNotInjected(contextRepository);
|
||||
ThrowIfNotInjected(instanceRepository);
|
||||
if (command is CancelRequest)
|
||||
{
|
||||
return CancelExecution(command);
|
||||
@@ -43,7 +43,7 @@ namespace mROA.Implementation.Backend
|
||||
if (invoker == null)
|
||||
throw new Exception($"Command {command.CommandId} not found");
|
||||
|
||||
var context = GetContext(command, contextRepository, invoker, endPointContext);
|
||||
var context = GetContext(command, instanceRepository, invoker, endPointContext);
|
||||
|
||||
if (context == null)
|
||||
throw new NullReferenceException("Instance can't be null");
|
||||
@@ -70,7 +70,7 @@ namespace mROA.Implementation.Backend
|
||||
var result = Execute((invoker as MethodInvoker)!, context, castedParams!, command, execContext);
|
||||
if (command.CommandId == -1)
|
||||
{
|
||||
contextRepository.ClearObject(command.ObjectId, endPointContext);
|
||||
instanceRepository.ClearObject(command.ObjectId, endPointContext);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -86,12 +86,12 @@ namespace mROA.Implementation.Backend
|
||||
}
|
||||
}
|
||||
|
||||
private static object GetContext(ICallRequest command, IContextRepository contextRepository,
|
||||
private static object GetContext(ICallRequest command, IInstanceRepository instanceRepository,
|
||||
IMethodInvoker invoker, IEndPointContext endPointContext)
|
||||
{
|
||||
var context = command.ObjectId.ContextId != -1
|
||||
? contextRepository.GetObject<object>(command.ObjectId, endPointContext)
|
||||
: contextRepository.GetSingleObject(invoker.SuitableType, endPointContext);
|
||||
? instanceRepository.GetObject<object>(command.ObjectId, endPointContext)
|
||||
: instanceRepository.GetSingleObject(invoker.SuitableType, endPointContext);
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace mROA.Implementation.Backend
|
||||
return castedParams;
|
||||
}
|
||||
|
||||
private void ThrowIfNotInjected(IContextRepository contextRepository)
|
||||
private void ThrowIfNotInjected(IInstanceRepository instanceRepository)
|
||||
{
|
||||
if (_cancellationRepo is null)
|
||||
throw new NullReferenceException("Method repository was not defined");
|
||||
@@ -114,7 +114,7 @@ namespace mROA.Implementation.Backend
|
||||
if (_methodRepo is null)
|
||||
throw new NullReferenceException("Method repository was not defined");
|
||||
|
||||
if (contextRepository is null)
|
||||
if (instanceRepository is null)
|
||||
throw new NullReferenceException("Context repository was not defined");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace mROA.Implementation.Backend
|
||||
{
|
||||
private IConnectionHub? _hub;
|
||||
|
||||
private IContextRepository? _contextRepository;
|
||||
private IContextRepository? _remoteContextRepository;
|
||||
private IInstanceRepository? _contextRepository;
|
||||
private IInstanceRepository? _remoteContextRepository;
|
||||
private IMethodRepository? _methodRepository;
|
||||
private IContextualSerializationToolKit? _serializationToolkit;
|
||||
private IExecuteModule? _executeModule;
|
||||
@@ -21,11 +21,11 @@ namespace mROA.Implementation.Backend
|
||||
_hub = connectionHub;
|
||||
_hub.OnConnected += HubOnOnConnected;
|
||||
break;
|
||||
case MultiClientContextRepository:
|
||||
case ContextRepository:
|
||||
_contextRepository = dependency as IContextRepository;
|
||||
case MultiClientInstanceRepository:
|
||||
case InstanceRepository:
|
||||
_contextRepository = dependency as IInstanceRepository;
|
||||
break;
|
||||
case RemoteContextRepository remoteContextRepository:
|
||||
case RemoteInstanceRepository remoteContextRepository:
|
||||
_remoteContextRepository = remoteContextRepository;
|
||||
break;
|
||||
case IMethodRepository methodRepository:
|
||||
|
||||
+2
-3
@@ -2,13 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Abstract;
|
||||
using mROA.Implementation.Attributes;
|
||||
|
||||
namespace mROA.Implementation.Backend
|
||||
{
|
||||
public class ContextRepository : IContextRepository
|
||||
public class InstanceRepository : IInstanceRepository
|
||||
{
|
||||
public static object[] EventBinders = { };
|
||||
|
||||
@@ -22,7 +21,7 @@ namespace mROA.Implementation.Backend
|
||||
private IStorage<object> _storage;
|
||||
|
||||
|
||||
public ContextRepository()
|
||||
public InstanceRepository()
|
||||
{
|
||||
_storage = new ExtensibleStorage<object>();
|
||||
}
|
||||
+6
-6
@@ -4,12 +4,12 @@ using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation.Backend
|
||||
{
|
||||
public class MultiClientContextRepository : IContextRepository, IContextRepositoryHub
|
||||
public class MultiClientInstanceRepository : IInstanceRepository, IContextRepositoryHub
|
||||
{
|
||||
private readonly Func<int, IContextRepository> _produceRepository;
|
||||
private readonly Dictionary<int, IContextRepository> _repositories = new();
|
||||
private readonly Func<int, IInstanceRepository> _produceRepository;
|
||||
private readonly Dictionary<int, IInstanceRepository> _repositories = new();
|
||||
|
||||
public MultiClientContextRepository(Func<int, IContextRepository> produceRepository)
|
||||
public MultiClientInstanceRepository(Func<int, IInstanceRepository> produceRepository)
|
||||
{
|
||||
_produceRepository = produceRepository;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace mROA.Implementation.Backend
|
||||
return repository.GetObjectIndex<T>(o, context);
|
||||
}
|
||||
|
||||
public IContextRepository GetRepository(int clientId)
|
||||
public IInstanceRepository GetRepository(int clientId)
|
||||
{
|
||||
var repository = GetRepositoryByClientId(clientId);
|
||||
return repository;
|
||||
@@ -61,7 +61,7 @@ namespace mROA.Implementation.Backend
|
||||
_repositories.Remove(clientId);
|
||||
}
|
||||
|
||||
private IContextRepository GetRepositoryByClientId(int clientId)
|
||||
private IInstanceRepository GetRepositoryByClientId(int clientId)
|
||||
{
|
||||
if (_repositories.TryGetValue(clientId, out var repository))
|
||||
return repository;
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Abstract;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Abstract;
|
||||
using static mROA.Implementation.EMessageType;
|
||||
|
||||
@@ -14,12 +14,11 @@ namespace mROA.Implementation
|
||||
private readonly ChannelWriter<NetworkMessageHeader> _untrustedWriter;
|
||||
private readonly Channel<NetworkMessageHeader> _outputTrustedChannel;
|
||||
private readonly Channel<NetworkMessageHeader> _outputUntrustedChannel;
|
||||
private Task<NetworkMessageHeader>? _currentReceiving;
|
||||
private IContextualSerializationToolKit? _serialization;
|
||||
private bool _isConnected = true;
|
||||
private bool _isActive = true;
|
||||
private TaskCompletionSource<Stream> _reconnection;
|
||||
public IEndPointContext Context { get; set; }
|
||||
private IEndPointContext? _context;
|
||||
|
||||
public ChannelInteractionModule()
|
||||
{
|
||||
@@ -50,7 +49,7 @@ namespace mROA.Implementation
|
||||
|
||||
public ChannelReader<NetworkMessageHeader> TrustedPostChanel => _outputTrustedChannel.Reader;
|
||||
public ChannelReader<NetworkMessageHeader> UntrustedPostChanel => _outputUntrustedChannel.Reader;
|
||||
public Func<bool> IsConnected { get; set; }
|
||||
public Func<bool> IsConnected { get; set; } = () => false;
|
||||
|
||||
public void Inject<T>(T dependency)
|
||||
{
|
||||
@@ -63,7 +62,7 @@ namespace mROA.Implementation
|
||||
ConnectionId = identityGenerator.GetNextIdentity();
|
||||
break;
|
||||
case IEndPointContext endpointContext:
|
||||
Context = endpointContext;
|
||||
_context = endpointContext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +93,6 @@ namespace mROA.Implementation
|
||||
if (_serialization == null)
|
||||
throw new NullReferenceException("Serialization toolkit is not initialized");
|
||||
|
||||
bool withError = false;
|
||||
while (true)
|
||||
{
|
||||
if (await PostMessageInternal(messageHeader))
|
||||
@@ -106,8 +104,7 @@ namespace mROA.Implementation
|
||||
}
|
||||
|
||||
_isConnected = false;
|
||||
withError = true;
|
||||
await MakeRecovery("OUT");
|
||||
await MakeRecovery();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,23 +120,21 @@ namespace mROA.Implementation
|
||||
if (sendRecovery)
|
||||
{
|
||||
await PostMessageAsync(
|
||||
new NetworkMessageHeader(_serialization!, new ClientRecovery(Math.Abs(ConnectionId)), Context));
|
||||
var ping = await ReceiveChanel.Reader.ReadAsync();
|
||||
new NetworkMessageHeader(_serialization!, new ClientRecovery(Math.Abs(ConnectionId)), _context));
|
||||
await ReceiveChanel.Reader.ReadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _trustedWriter.WriteAsync(new NetworkMessageHeader());
|
||||
}
|
||||
|
||||
var setting = _reconnection.TrySetResult(null);
|
||||
// _isInReconnectionState = false;
|
||||
_reconnection.TrySetResult(Stream.Null);
|
||||
_isConnected = true;
|
||||
_reconnection = new TaskCompletionSource<Stream>();
|
||||
}
|
||||
|
||||
private async Task MakeRecovery(string source)
|
||||
private async Task MakeRecovery()
|
||||
{
|
||||
//TODO переделать реконнект
|
||||
lock (_reconnection)
|
||||
{
|
||||
OnDisconnected?.Invoke(ConnectionId);
|
||||
@@ -154,10 +149,6 @@ namespace mROA.Implementation
|
||||
public void Dispose()
|
||||
{
|
||||
_isActive = false;
|
||||
if (_currentReceiving is { IsCompleted: true })
|
||||
{
|
||||
_currentReceiving?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class StreamExtractor
|
||||
@@ -167,15 +158,14 @@ namespace mROA.Implementation
|
||||
private const int BufferSize = ushort.MaxValue;
|
||||
private readonly Memory<byte> _buffer = new byte[BufferSize];
|
||||
private bool _manualConnectionState = true;
|
||||
private IEndPointContext Context;
|
||||
public readonly int Id = new Random().Next();
|
||||
private readonly IEndPointContext _context;
|
||||
|
||||
public StreamExtractor(Stream ioStream, IContextualSerializationToolKit serializationToolkit,
|
||||
IEndPointContext context)
|
||||
{
|
||||
_ioStream = ioStream;
|
||||
_serializationToolkit = serializationToolkit;
|
||||
Context = context;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public Action<NetworkMessageHeader> MessageReceived = _ => { };
|
||||
@@ -197,14 +187,14 @@ namespace mROA.Implementation
|
||||
return len;
|
||||
}
|
||||
|
||||
public async Task SingleReceive(CancellationToken Token = default)
|
||||
public async Task SingleReceive(CancellationToken token = default)
|
||||
{
|
||||
var len = ReadMessageLength();
|
||||
var localSpan = _buffer[..len];
|
||||
|
||||
await _ioStream.ReadExactlyAsync(localSpan, cancellationToken: Token);
|
||||
await _ioStream.ReadExactlyAsync(localSpan, cancellationToken: token);
|
||||
|
||||
var message = _serializationToolkit.Deserialize<NetworkMessageHeader>(localSpan, Context);
|
||||
var message = _serializationToolkit.Deserialize<NetworkMessageHeader>(localSpan, _context);
|
||||
MessageReceived(message);
|
||||
}
|
||||
|
||||
@@ -216,9 +206,9 @@ namespace mROA.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Send(NetworkMessageHeader message, CancellationToken token = default)
|
||||
private async Task Send(NetworkMessageHeader message, CancellationToken token = default)
|
||||
{
|
||||
var rawMessage = _serializationToolkit.Serialize(message, Context);
|
||||
var rawMessage = _serializationToolkit.Serialize(message, _context);
|
||||
var header = BitConverter.GetBytes((ushort)rawMessage.Length).AsMemory(0, sizeof(ushort));
|
||||
|
||||
await _ioStream.WriteAsync(header, token);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
public class ComplexContextRepository : IContextRepository
|
||||
public class ComplexInstanceRepository : IInstanceRepository
|
||||
{
|
||||
private List<KeyValuePair<int, ExtensibleStorage<object>>> _storages = new();
|
||||
public static object[] EventBinders = { };
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using mROA.Abstract;
|
||||
using mROA.Implementation.Backend;
|
||||
|
||||
@@ -6,8 +5,8 @@ namespace mROA.Implementation
|
||||
{
|
||||
public class EndPointContext : IEndPointContext
|
||||
{
|
||||
public IContextRepository RealRepository { get; set; }
|
||||
public IContextRepository RemoteRepository { get; set; }
|
||||
public IInstanceRepository RealRepository { get; set; }
|
||||
public IInstanceRepository RemoteRepository { get; set; }
|
||||
public int HostId { get; set; }
|
||||
|
||||
public int OwnerId { get; set; }
|
||||
@@ -16,10 +15,10 @@ namespace mROA.Implementation
|
||||
{
|
||||
switch (dependency)
|
||||
{
|
||||
case RemoteContextRepository remoteRepository:
|
||||
case RemoteInstanceRepository remoteRepository:
|
||||
RemoteRepository = remoteRepository;
|
||||
break;
|
||||
case ContextRepository realRepository:
|
||||
case InstanceRepository realRepository:
|
||||
RealRepository = realRepository;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using mROA.Abstract;
|
||||
|
||||
namespace mROA.Abstract
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
public class EventBinder<T> : IEventBinder<T>
|
||||
{
|
||||
public Action<T, IEndPointContext, IRepresentationModuleProducer, int> BindAction { get; set; }
|
||||
public Action<T, IEndPointContext, IRepresentationModuleProducer, int> BindAction { get; set; } = (_, _, _, _) => { };
|
||||
|
||||
public void BindEvents(T source, IEndPointContext context,
|
||||
IRepresentationModuleProducer representationModuleProducer, int index)
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
// public class JsonSerializationToolkit : IContextualSerializationToolKit
|
||||
// {
|
||||
// public byte[] Serialize<T>(T objectToSerialize)
|
||||
// {
|
||||
// return JsonSerializer.SerializeToUtf8Bytes(objectToSerialize);
|
||||
// }
|
||||
//
|
||||
// public byte[] Serialize(object objectToSerialize, Type type)
|
||||
// {
|
||||
// return JsonSerializer.SerializeToUtf8Bytes(objectToSerialize, type);
|
||||
// }
|
||||
//
|
||||
// public T? Deserialize<T>(byte[] rawData)
|
||||
// {
|
||||
// return JsonSerializer.Deserialize<T>(rawData);
|
||||
// }
|
||||
//
|
||||
// public object? Deserialize(byte[] rawData, Type type)
|
||||
// {
|
||||
// return JsonSerializer.Deserialize(rawData, type);
|
||||
// }
|
||||
//
|
||||
// public T? Deserialize<T>(Span<byte> rawData)
|
||||
// {
|
||||
// return JsonSerializer.Deserialize<T>(rawData);
|
||||
// }
|
||||
//
|
||||
// public object? Deserialize(Span<byte> rawData, Type type)
|
||||
// {
|
||||
// return JsonSerializer.Deserialize(rawData, type);
|
||||
// }
|
||||
//
|
||||
// public T Cast<T>(object nonCasted)
|
||||
// {
|
||||
// return nonCasted switch
|
||||
// {
|
||||
// JsonElement jsonElement => jsonElement.Deserialize<T>()!,
|
||||
// T casted => casted,
|
||||
// _ => throw new JsonException("Cannot cast object to type " + typeof(T).FullName)
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public object Cast(object nonCasted, Type type)
|
||||
// {
|
||||
// if (nonCasted is JsonElement jsonElement)
|
||||
// return jsonElement.Deserialize(type)!;
|
||||
//
|
||||
// throw new JsonException("Cannot cast object to type " + type.FullName);
|
||||
// }
|
||||
//
|
||||
// public void Inject<T>(T dependency)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace mROA.Implementation
|
||||
public bool IsTrusted { get; set; } = true;
|
||||
public Type[] ParameterTypes { get; set; } = Type.EmptyTypes;
|
||||
public Type? ReturnType { get; set; }
|
||||
public Type SuitableType { get; set; }
|
||||
public Type SuitableType { get; set; } = typeof(object);
|
||||
|
||||
public Action<object, object?[]?, object[], Action<object?>> Invoking { get; set; } =
|
||||
(_, _, _, post) => { post.Invoke(null); };
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using mROA.Abstract;
|
||||
using mROA.Implementation.Attributes;
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
@@ -9,7 +7,7 @@ namespace mROA.Implementation
|
||||
{
|
||||
public class NetworkMessageHeader
|
||||
{
|
||||
protected bool Equals(NetworkMessageHeader other)
|
||||
private bool Equals(NetworkMessageHeader other)
|
||||
{
|
||||
return Id.Equals(other.Id) && MessageType == other.MessageType;
|
||||
}
|
||||
@@ -22,11 +20,6 @@ namespace mROA.Implementation
|
||||
return Equals((NetworkMessageHeader)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Id, (int)MessageType);
|
||||
}
|
||||
|
||||
public static readonly NetworkMessageHeader Null = new();
|
||||
public NetworkMessageHeader()
|
||||
{
|
||||
@@ -43,13 +36,8 @@ namespace mROA.Implementation
|
||||
}
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public EMessageType MessageType { get; set; }
|
||||
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[SerializationIgnore]
|
||||
public object Parced { get; set; }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
public class RemoteContextRepository : IContextRepository
|
||||
public class RemoteInstanceRepository : IInstanceRepository
|
||||
{
|
||||
private List<RemoteObjectBase> _producedRemoteEndpoints = new();
|
||||
public static Dictionary<Type, Type> RemoteTypes = new();
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Abstract;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using mROA.Abstract;
|
||||
#pragma warning disable CS8602 // Dereference of a possibly null reference.
|
||||
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
|
||||
@@ -20,12 +20,14 @@ namespace mROA.Implementation
|
||||
{
|
||||
private ComplexObjectIdentifier _identifier = ComplexObjectIdentifier.Null;
|
||||
|
||||
private T _value;
|
||||
private T? _value;
|
||||
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public SharedObjectShellShell()
|
||||
{
|
||||
_value = default;
|
||||
EndPointContext = new EndPointContext();
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
@@ -41,7 +43,7 @@ namespace mROA.Implementation
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public T Value
|
||||
{
|
||||
get => _value;
|
||||
get => _value!;
|
||||
set
|
||||
{
|
||||
_value = value;
|
||||
@@ -76,11 +78,11 @@ namespace mROA.Implementation
|
||||
|
||||
public object UniversalValue
|
||||
{
|
||||
get => _value;
|
||||
get => _value!;
|
||||
set => _value = (T)value;
|
||||
}
|
||||
|
||||
private IContextRepository GetDefaultContextRepository() =>
|
||||
private IInstanceRepository GetDefaultContextRepository() =>
|
||||
(_identifier.OwnerId == EndPointContext.HostId
|
||||
? EndPointContext.RealRepository
|
||||
: EndPointContext.RemoteRepository) ??
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation
|
||||
{
|
||||
#pragma warning disable CS8618, CS9264
|
||||
public static class TransmissionConfig
|
||||
{
|
||||
#if TRACE
|
||||
public static int TotalTransmittedBytes { get; set; }
|
||||
#endif
|
||||
// private static IContextRepository? _realContextRepository;
|
||||
// private static IContextRepository? _remoteEndpointContextRepository;
|
||||
// private static IOwnershipRepository? _ownershipRepository;
|
||||
//
|
||||
// public static IContextRepository RealContextRepository
|
||||
// {
|
||||
// get => _realContextRepository ?? throw new NullReferenceException("RealContextRepository is null");
|
||||
// set => _realContextRepository = value;
|
||||
// }
|
||||
//
|
||||
// public static IContextRepository RemoteEndpointContextRepository
|
||||
// {
|
||||
// get => _remoteEndpointContextRepository ??
|
||||
// throw new NullReferenceException("RemoteEndpointContextRepository is null");
|
||||
// set => _remoteEndpointContextRepository = value;
|
||||
// }
|
||||
//
|
||||
// public static IOwnershipRepository OwnershipRepository
|
||||
// {
|
||||
// get => _ownershipRepository ?? throw new NullReferenceException("OwnershipRepository is null");
|
||||
// set => _ownershipRepository = value;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user