From 9328f1c4e60536177ac7bfe8a44495de46ad8065 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Thu, 13 Feb 2025 22:02:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=B0=D1=81=D0=B8=D0=BD=D1=85?= =?UTF-8?q?=D1=80=D0=BE=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mROA/Implementation/SharedObject.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mROA/Implementation/SharedObject.cs b/mROA/Implementation/SharedObject.cs index a8378e4..6366c1a 100644 --- a/mROA/Implementation/SharedObject.cs +++ b/mROA/Implementation/SharedObject.cs @@ -19,12 +19,16 @@ public class SharedObject where T : notnull throw new NullReferenceException( "DefaultContextRepository was not defined"); - private int _contextId = -1; + private int _contextId = -2; private int _ownerId = -1; public int OwnerId { - get => _ownerId == -1 ? TransmissionConfig.OwnershipRepository!.GetOwnershipId() : _ownerId; + get + { + _ownerId = _ownerId == -1 ? TransmissionConfig.OwnershipRepository!.GetOwnershipId() : _ownerId; + return _ownerId; + } set => _ownerId = value; } @@ -32,7 +36,14 @@ public class SharedObject where T : notnull public int ContextId { // ReSharper disable once UnusedMember.Global - get => _contextId; + get + { + if (_contextId != -2) + return _contextId; + + _contextId = TransmissionConfig.RealContextRepository!.GetObjectIndex(Value); + return _contextId; + } init { _contextId = value; @@ -40,8 +51,7 @@ public class SharedObject where T : notnull } } - [JsonIgnore] - public T Value { get; private set; } + [JsonIgnore] public T Value { get; private set; } // ReSharper disable once MemberCanBePrivate.Global public SharedObject() @@ -63,8 +73,6 @@ public class SharedObject where T : notnull _contextId = TransmissionConfig.RealContextRepository!.GetObjectIndex(value); _ownerId = TransmissionConfig.OwnershipRepository!.GetOwnershipId(); } - - } public static implicit operator T(SharedObject value) => value.Value;