diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs index 4bf4836bbc..a2b46c8e58 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentComponentComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs index 73d3d82307..5912d607bc 100644 --- a/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/dependentschema/DependentDataComponentComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId en public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId en public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs index 0bf5c089eb..5afc603fae 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestChildComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entit public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entit public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs index ed4020388a..d4418d67e0 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entityId) public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entityId) public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs index d5c310ae8f..5581243b52 100644 --- a/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/tests/DependencyTestGrandchildComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs index 541423573a..61ccadc905 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ComponentUsingNestedTypeSameNameComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(E public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(E public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs index 08724617c4..c5cc90da28 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveEntityComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs index bc5b59fc37..fea0ecec81 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapKeyComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entityId public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs index 11daeba6d8..34b15f9ea7 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveMapValueComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs index 2a3385a1a0..d0f70ffa74 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveOptionalComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs index b5a910931f..362e067968 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveRepeatedComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs index 27c30b1517..37390630c2 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/ExhaustiveSingularComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } } diff --git a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs index ae379b2974..344d2595a0 100644 --- a/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs +++ b/test-project/Assets/Generated/Source/improbable/testschema/RecursiveComponentComponentReaderWriter.cs @@ -102,12 +102,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToReaderSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -124,7 +119,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } @@ -227,12 +224,7 @@ public override Subscription Subscribe(EntityId entity public override void Cancel(ISubscription subscription) { var sub = ((Subscription) subscription); - if (sub.HasValue) - { - var reader = sub.Value; - reader.IsValid = false; - reader.RemoveAllCallbacks(); - } + ResetValue(sub); var subscriptions = entityIdToWriterSubscriptions[sub.EntityId]; subscriptions.Remove(sub); @@ -249,7 +241,9 @@ public override void ResetValue(ISubscription subscription) var sub = ((Subscription) subscription); if (sub.HasValue) { - sub.Value.RemoveAllCallbacks(); + var reader = sub.Value; + reader.IsValid = false; + reader.RemoveAllCallbacks(); } } }