NewIsNotArrayHeader() private method

private NewIsNotArrayHeader ( ) : Exception
return System.Exception
コード例 #1
0
        public static void UnpackCollectionTo <T>(Unpacker unpacker, MessagePackSerializer <T> serializer, IEnumerable <T> collection, Action <T> addition)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }


            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }


            if (addition == null)
            {
                throw new ArgumentNullException("addition");
            }

            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }

#if !UNITY
            Contract.EndContractBlock();
#endif // !UNITY

            int count = GetItemsCount(unpacker);
            for (int i = 0; i < count; i++)
            {
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                T item;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    item = serializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        item = serializer.UnpackFrom(subtreeUnpacker);
                    }
                }

                addition(item);
            }
        }
コード例 #2
0
        public static void UnpackArrayTo <T>(Unpacker unpacker, MessagePackSerializer <T> serializer, T[] array)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            if (array == null)
            {
                throw new ArgumentNullException("array");
            }

            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }

#if !UNITY
            Contract.EndContractBlock();
#endif // !UNITY

            int count = GetItemsCount(unpacker);
            for (int i = 0; i < count; i++)
            {
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                T item;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    item = serializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        item = serializer.UnpackFrom(subtreeUnpacker);
                    }
                }

                array[i] = item;
            }
        }
コード例 #3
0
        public static void UnpackCollectionTo <TDiscarded>(Unpacker unpacker, IEnumerable collection, Func <object, TDiscarded> addition)
        {
#if DEBUG
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }

            Contract.EndContractBlock();
#endif

            int count = GetItemsCount(unpacker);
            for (int i = 0; i < count; i++)
            {
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                MessagePackObject item;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    item = _messagePackObjectSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        item = _messagePackObjectSerializer.UnpackFrom(subtreeUnpacker);
                    }
                }

                addition(item);
            }
        }
コード例 #4
0
        public static void UnpackArrayTo <T>(Unpacker unpacker, MessagePackSerializer <T> serializer, T[] array)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }
            int itemsCount = GetItemsCount(unpacker);

            for (int i = 0; i < itemsCount; i++)
            {
                T local;
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    local = serializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker unpacker2 = unpacker.ReadSubtree())
                    {
                        local = serializer.UnpackFrom(unpacker2);
                    }
                }
                array[i] = local;
            }
        }
コード例 #5
0
        public static void UnpackCollectionTo <T, TDiscarded>(Unpacker unpacker, MessagePackSerializer <T> serializer, IEnumerable <T> collection, Func <T, TDiscarded> addition)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }
            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }
            int itemsCount = GetItemsCount(unpacker);

            for (int i = 0; i < itemsCount; i++)
            {
                T local;
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    local = serializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker unpacker2 = unpacker.ReadSubtree())
                    {
                        local = serializer.UnpackFrom(unpacker2);
                    }
                }
                addition(local);
            }
        }
コード例 #6
0
        public static void UnpackCollectionTo(Unpacker unpacker, IEnumerable collection, Action <object> addition)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }
            if (!unpacker.IsArrayHeader)
            {
                throw SerializationExceptions.NewIsNotArrayHeader();
            }
            int itemsCount = GetItemsCount(unpacker);

            for (int i = 0; i < itemsCount; i++)
            {
                MessagePackObject obj2;
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    obj2 = _messagePackObjectSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker unpacker2 = unpacker.ReadSubtree())
                    {
                        obj2 = _messagePackObjectSerializer.UnpackFrom(unpacker2);
                    }
                }
                addition(obj2);
            }
        }