diff --git a/SystemExtensions.NetStandard/Extensions/StreamExtensions.cs b/SystemExtensions.NetStandard/Extensions/StreamExtensions.cs index db0183c..25cfab4 100644 --- a/SystemExtensions.NetStandard/Extensions/StreamExtensions.cs +++ b/SystemExtensions.NetStandard/Extensions/StreamExtensions.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Text; namespace System.Extensions { @@ -36,5 +37,31 @@ namespace System.Extensions stream.Seek(0, SeekOrigin.Begin); return stream; } + + public static string ReadUntil(this StreamReader sr, string delim) + { + var sb = new StringBuilder(); + bool found = false; + + while (!found && !sr.EndOfStream) + { + for (int i = 0; i < delim.Length; i++) + { + char c = (char)sr.Read(); + sb.Append(c); + + if (c != delim[i]) + break; + + if (i == delim.Length - 1) + { + sb.Remove(sb.Length - delim.Length, delim.Length); + found = true; + } + } + } + + return sb.ToString(); + } } } diff --git a/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj b/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj index 5b1377d..cefef3b 100644 --- a/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj +++ b/SystemExtensions.NetStandard/SystemExtensions.NetStandard.csproj @@ -6,7 +6,7 @@ LICENSE true System - 1.1.1 + 1.1.2 Alexandru Macocian https://github.com/AlexMacocian/SystemExtensions