Esempio n. 1
0
        protected internal override T UnpackFromCore(Unpacker unpacker)
        {
            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }

            var itemsCount = UnpackHelpers.GetItemsCount(unpacker);

            if (itemsCount != this._itemSerializers.Count)
            {
                throw SerializationExceptions.NewTupleCardinarityIsNotMatch(this._itemSerializers.Count, itemsCount);
            }

            var unpackedItems = new List <object>(this._itemSerializers.Count);

            for (var i = 0; i < this._itemSerializers.Count; i++)
            {
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                unpackedItems.Add(this._itemSerializers[i].UnpackFrom(unpacker));
            }

            return(this.CreateTuple(unpackedItems));
        }
        protected internal override T UnpackFromCore(Unpacker unpacker)
        {
            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }

            if (( int )unpacker.ItemsCount != this._itemSerializers.Length)
            {
                throw SerializationExceptions.NewTupleCardinarityIsNotMatch(this._itemSerializers.Length, ( int )unpacker.ItemsCount);
            }

            return(this._unpackFromCore(unpacker, this._itemSerializers));
        }