private static async Task <SecurityType[]> ParseSecurityTypesAsync(PipeReader reader, CancellationToken token) { SecurityType[] types; var typesLength = await reader.ReadByteAsync(token); if (typesLength == 0) { throw new NoSecurityTypesException(); } types = new SecurityType[typesLength]; for (var i = 0; i < typesLength; ++i) { types[i] = (SecurityType)await reader.ReadByteAsync(token); } return(types); }