#define TRACE using System.Diagnostics; using System.IO; using ArchestrAServices.Common; namespace ArchestrAServices.ASBContract; public class MemoryStreamHelper { public static bool ValidateStream(BinaryReader reader) { if (reader == null || reader.BaseStream == null || reader.BaseStream.Length <= 0) { return false; } return true; } public static bool ValidateStream(BinaryReader reader, int arrayCnt) { bool result = false; if (ValidateStream(reader)) { reader.BaseStream.Position = 0L; int num = reader.ReadInt32(); if (num != arrayCnt) { SvcTrace.DiagDiagnostics.TraceEvent(TraceEventType.Warning, 0, $" MemoryStreamHelper: ValidateStream. Array count{arrayCnt}, doesn't match with the actual count {num}"); } else { result = true; } } return result; } }