Exemplo n.º 1
0
        public static bool TryDeserializeValues <T>(ref SequenceReader <byte> input, int length, out T[] values) where T : new()
        {
            if (length == 0)
            {
                values = Array.Empty <T>();
                return(true);
            }

            values = new T[length];
            for (var i = 0; i < length; i++)
            {
                var current = new T();
                var b       = input.GetRemainingSequence();
                if (!TryDeserialize(ref b, current, out var bytesRead))
                {
                    values = Array.Empty <T>();
                    return(false);
                }

                values[i] = current;
                input.Advance(bytesRead);
            }

            return(true);
        }