public static ParsedLine ReadLine(this byte[] source, int startIndex)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (startIndex < 0)
{
throw new ArgumentOutOfRangeException("startIndex", "Parameter is expected gretaer or equal than zero.");
}
if (startIndex >= source.Length)
{
return new ParsedLine(-1, null);
}
int currentIndex = startIndex - 1;
int indexModifier = 0;
while (indexModifier == 0 && ++currentIndex < source.Length)
{
int num = source[currentIndex];
switch (num)
{
case 13:
if ((currentIndex != (source.Length - 1)) && (source[currentIndex + 1] == 10))
{
indexModifier = 2;
}
break;
case 10:
indexModifier = 1;
break;
}
}
var output = new byte[currentIndex - startIndex];
Array.Copy(source, startIndex, output, 0, currentIndex - startIndex);
return new ParsedLine (currentIndex + indexModifier, output);
}