Функционал TransmittionConfig вынесен в не статический EndpointContext
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using mROA.Abstract;
|
using mROA.Abstract;
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
@@ -40,10 +41,18 @@ namespace mROA.Implementation
|
|||||||
|
|
||||||
public class SharedObject<T> : ISharedObject where T : notnull
|
public class SharedObject<T> : ISharedObject where T : notnull
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public IEndPointContext EndPointContext { get; set; } = new EndPointContext
|
||||||
|
{
|
||||||
|
RealRepository = TransmissionConfig.RealContextRepository,
|
||||||
|
RemoteRepository = TransmissionConfig.RemoteEndpointContextRepository,
|
||||||
|
HostId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId(),
|
||||||
|
OwnerFunc = TransmissionConfig.OwnershipRepository.GetOwnershipId
|
||||||
|
};
|
||||||
private IContextRepository GetDefaultContextRepository() =>
|
private IContextRepository GetDefaultContextRepository() =>
|
||||||
(OwnerId == TransmissionConfig.OwnershipRepository.GetHostOwnershipId()
|
(OwnerId == EndPointContext.HostId
|
||||||
? TransmissionConfig.RealContextRepository
|
? EndPointContext.RealRepository
|
||||||
: TransmissionConfig.RemoteEndpointContextRepository) ??
|
: EndPointContext.RemoteRepository) ??
|
||||||
throw new NullReferenceException(
|
throw new NullReferenceException(
|
||||||
"DefaultContextRepository was not defined");
|
"DefaultContextRepository was not defined");
|
||||||
|
|
||||||
@@ -54,7 +63,7 @@ namespace mROA.Implementation
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_ownerId = _ownerId == -1 ? TransmissionConfig.OwnershipRepository.GetOwnershipId() : _ownerId;
|
_ownerId = _ownerId == -1 ? EndPointContext.OwnerId : _ownerId;
|
||||||
return _ownerId;
|
return _ownerId;
|
||||||
}
|
}
|
||||||
set => _ownerId = value;
|
set => _ownerId = value;
|
||||||
@@ -69,7 +78,7 @@ namespace mROA.Implementation
|
|||||||
if (_contextId != -2)
|
if (_contextId != -2)
|
||||||
return _contextId;
|
return _contextId;
|
||||||
|
|
||||||
_contextId = TransmissionConfig.RealContextRepository.GetObjectIndex(Value);
|
_contextId = EndPointContext.RealRepository.GetObjectIndex(Value);
|
||||||
return _contextId;
|
return _contextId;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
@@ -99,7 +108,7 @@ namespace mROA.Implementation
|
|||||||
_contextId = ro.Id;
|
_contextId = ro.Id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_ownerId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId();
|
_ownerId = EndPointContext.HostId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator T(SharedObject<T> value) => value.Value;
|
public static implicit operator T(SharedObject<T> value) => value.Value;
|
||||||
@@ -107,13 +116,5 @@ 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
|
|
||||||
{
|
|
||||||
RealRepository = TransmissionConfig.RealContextRepository,
|
|
||||||
RemoteRepository = TransmissionConfig.RemoteEndpointContextRepository,
|
|
||||||
HostId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId(),
|
|
||||||
OwnerFunc = TransmissionConfig.OwnershipRepository.GetOwnershipId
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user