From df4f258290e7f667b9828441454c5f11bac790f5 Mon Sep 17 00:00:00 2001 From: Michael Croes Date: Mon, 31 May 2021 21:23:32 +0200 Subject: [PATCH] Move GetStreamIfAvailable to PLC.cs --- S7.Net/PLC.cs | 11 +++++++++++ S7.Net/PlcAsynchronous.cs | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index 3a73b4c..b7ede94 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net.Sockets; using S7.Net.Protocol; @@ -242,6 +243,16 @@ namespace S7.Net } } + private Stream GetStreamIfAvailable() + { + if (_stream == null) + { + throw new PlcException(ErrorCode.ConnectionError, "Plc is not connected"); + } + + return _stream; + } + #region IDisposable Support private bool disposedValue = false; // To detect redundant calls diff --git a/S7.Net/PlcAsynchronous.cs b/S7.Net/PlcAsynchronous.cs index 7730b3a..3e523d8 100644 --- a/S7.Net/PlcAsynchronous.cs +++ b/S7.Net/PlcAsynchronous.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Net.Sockets; using System.Threading.Tasks; using S7.Net.Protocol; -using System.IO; using System.Threading; using S7.Net.Protocol.S7; @@ -502,15 +501,6 @@ namespace S7.Net } } - private Stream GetStreamIfAvailable() - { - if (_stream == null) - { - throw new PlcException(ErrorCode.ConnectionError, "Plc is not connected"); - } - return _stream; - } - private async Task RequestTpduAsync(byte[] requestData, CancellationToken cancellationToken = default) { var stream = GetStreamIfAvailable();