From abd72b9e0de7a1747e6794718884a3bd5efc56f6 Mon Sep 17 00:00:00 2001 From: SuhorukovAnton Date: Wed, 29 Dec 2021 18:49:02 +0300 Subject: [PATCH] analizators/s3903 --- common/ASC.Common/Data/StreamExtension.cs | 38 +++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/common/ASC.Common/Data/StreamExtension.cs b/common/ASC.Common/Data/StreamExtension.cs index c856976971..c27b05eee1 100644 --- a/common/ASC.Common/Data/StreamExtension.cs +++ b/common/ASC.Common/Data/StreamExtension.cs @@ -27,22 +27,26 @@ using System; using System.IO; -public static class StreamExtension -{ - public const int BufferSize = 2048; //NOTE: set to 2048 to fit in minimum tcp window - - public static void StreamCopyTo(this Stream srcStream, Stream dstStream, int length) - { - if (srcStream == null) throw new ArgumentNullException("srcStream"); - if (dstStream == null) throw new ArgumentNullException("dstStream"); - var buffer = new byte[BufferSize]; - int totalRead = 0; - int readed; - while ((readed = srcStream.Read(buffer, 0, length - totalRead > BufferSize ? BufferSize : length - totalRead)) > 0 && totalRead < length) +namespace ASC.Common.Data +{ + public static class StreamExtension + { + public const int BufferSize = 2048; //NOTE: set to 2048 to fit in minimum tcp window + + public static void StreamCopyTo(this Stream srcStream, Stream dstStream, int length) { - dstStream.Write(buffer, 0, readed); - totalRead += readed; - } - } -} + if (srcStream == null) throw new ArgumentNullException("srcStream"); + if (dstStream == null) throw new ArgumentNullException("dstStream"); + + var buffer = new byte[BufferSize]; + int totalRead = 0; + int readed; + while ((readed = srcStream.Read(buffer, 0, length - totalRead > BufferSize ? BufferSize : length - totalRead)) > 0 && totalRead < length) + { + dstStream.Write(buffer, 0, readed); + totalRead += readed; + } + } + } +} \ No newline at end of file