From 770e9488fad76cdf987e6992f84ff4064b5afcfb Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 13 三月 2026 13:28:54 +0800
Subject: [PATCH] fix: address code quality issues in I/Q/T/C regions
---
Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryRegion.cs | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryRegion.cs b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryRegion.cs
index 6ebd64c..b50ca96 100644
--- a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryRegion.cs
+++ b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Core/Memory/MemoryRegion.cs
@@ -49,6 +49,9 @@
/// </summary>
public virtual byte[] Read(ushort offset, ushort length)
{
+ if (_disposed)
+ throw new ObjectDisposedException(nameof(MemoryRegion));
+
_lock.EnterReadLock();
try
{
@@ -71,6 +74,9 @@
/// </summary>
public virtual void Write(ushort offset, byte[] data)
{
+ if (_disposed)
+ throw new ObjectDisposedException(nameof(MemoryRegion));
+
if (data == null)
throw new ArgumentNullException(nameof(data));
@@ -94,6 +100,9 @@
/// </summary>
public virtual void Clear()
{
+ if (_disposed)
+ throw new ObjectDisposedException(nameof(MemoryRegion));
+
_lock.EnterWriteLock();
try
{
--
Gitblit v1.9.3