NewIsNotMapHeader() 개인적인 메소드

private NewIsNotMapHeader ( ) : Exception
리턴 System.Exception
예제 #1
0
        public static void UnpackMapTo <TKey, TValue>(Unpacker unpacker, MessagePackSerializer <TKey> keySerializer, MessagePackSerializer <TValue> valueSerializer, IDictionary <TKey, TValue> dictionary)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }
            if (dictionary == null)
            {
                throw new ArgumentNullException("dictionary");
            }
            if (!unpacker.IsMapHeader)
            {
                throw SerializationExceptions.NewIsNotMapHeader();
            }
            int itemsCount = GetItemsCount(unpacker);

            for (int i = 0; i < itemsCount; i++)
            {
                TKey     local;
                Unpacker unpacker2;
                TValue   local2;
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    local = keySerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (unpacker2 = unpacker.ReadSubtree())
                    {
                        local = keySerializer.UnpackFrom(unpacker2);
                    }
                }
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    local2 = valueSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (unpacker2 = unpacker.ReadSubtree())
                    {
                        local2 = valueSerializer.UnpackFrom(unpacker2);
                    }
                }
                dictionary.Add(local, local2);
            }
        }
예제 #2
0
        public static void UnpackMapTo(Unpacker unpacker, IDictionary dictionary)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }
            if (dictionary == null)
            {
                throw new ArgumentNullException("dictionary");
            }
            if (!unpacker.IsMapHeader)
            {
                throw SerializationExceptions.NewIsNotMapHeader();
            }
            int itemsCount = GetItemsCount(unpacker);

            for (int i = 0; i < itemsCount; i++)
            {
                MessagePackObject obj2;
                Unpacker          unpacker2;
                MessagePackObject obj3;
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    obj2 = _messagePackObjectSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (unpacker2 = unpacker.ReadSubtree())
                    {
                        obj2 = _messagePackObjectSerializer.UnpackFrom(unpacker2);
                    }
                }
                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }
                if (!(unpacker.IsArrayHeader || unpacker.IsMapHeader))
                {
                    obj3 = _messagePackObjectSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (unpacker2 = unpacker.ReadSubtree())
                    {
                        obj3 = _messagePackObjectSerializer.UnpackFrom(unpacker2);
                    }
                }
                dictionary.Add(obj2, obj3);
            }
        }
예제 #3
0
        public static void UnpackMapTo(Unpacker unpacker, IDictionary dictionary)
        {
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

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

            if (!unpacker.IsMapHeader)
            {
                throw SerializationExceptions.NewIsNotMapHeader();
            }

            Contract.EndContractBlock();

            int count = GetItemsCount(unpacker);

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

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


                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

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

                dictionary.Add(key, value);
            }
        }
예제 #4
0
        public static void UnpackMapTo <TKey, TValue>(Unpacker unpacker, MessagePackSerializer keySerializer, MessagePackSerializer valueSerializer, Dictionary <TKey, TValue> dictionary)

        {
#if DEBUG
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

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

            if (!unpacker.IsMapHeader)
            {
                throw SerializationExceptions.NewIsNotMapHeader();
            }

            Contract.EndContractBlock();
#endif

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

                TKey key;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    key = (TKey)keySerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        key = (TKey)keySerializer.UnpackFrom(subtreeUnpacker);
                    }
                }


                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                TValue value;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    value = (TValue)valueSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        value = (TValue)valueSerializer.UnpackFrom(subtreeUnpacker);
                    }
                }

                dictionary.Add(key, value);
            }
        }
예제 #5
0
        public static void UnpackMapToDictionary(Unpacker unpacker, MessagePackSerializer keySerializer, MessagePackSerializer valueSerializer, object dictionary)
        {
#if DEBUG
            if (unpacker == null)
            {
                throw new ArgumentNullException("unpacker");
            }

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

            if (!unpacker.IsMapHeader)
            {
                throw SerializationExceptions.NewIsNotMapHeader();
            }

            Contract.EndContractBlock();
#endif

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

                object key;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    key = keySerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        key = keySerializer.UnpackFrom(subtreeUnpacker);
                    }
                }


                if (!unpacker.Read())
                {
                    throw SerializationExceptions.NewMissingItem(i);
                }

                object value;
                if (!unpacker.IsArrayHeader && !unpacker.IsMapHeader)
                {
                    value = valueSerializer.UnpackFrom(unpacker);
                }
                else
                {
                    using (Unpacker subtreeUnpacker = unpacker.ReadSubtree())
                    {
                        value = valueSerializer.UnpackFrom(subtreeUnpacker);
                    }
                }

                var addMethod = dictionary.GetType().GetMethod("Add", new[] { keySerializer.TargetType, valueSerializer.TargetType });

                addMethod.Invoke(dictionary, new[] { key, value });
            }
        }