DeserializeHelper() static private method

static private DeserializeHelper ( Type tItem, IParser parser, Func nestedObjectDeserializer, IList result, bool canUpdate ) : void
tItem System.Type
parser IParser
nestedObjectDeserializer Func
result IList
canUpdate bool
return void
Beispiel #1
0
        bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func <IParser, Type, object> nestedObjectDeserializer, out object value)
        {
            if (!expectedType.IsArray)
            {
                value = false;
                return(false);
            }
            Type      elementType = expectedType.GetElementType();
            ArrayList arrayList   = new ArrayList();

            CollectionNodeDeserializer.DeserializeHelper(elementType, parser, nestedObjectDeserializer, arrayList, true);
            Array array = Array.CreateInstance(elementType, arrayList.Count);

            arrayList.CopyTo(array, 0);
            value = array;
            return(true);
        }
Beispiel #2
0
        bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func <IParser, Type, object?> nestedObjectDeserializer, out object?value)
        {
            if (!expectedType.IsArray)
            {
                value = false;
                return(false);
            }

            var itemType = expectedType.GetElementType() !; // Arrays always have an element type

            var items = new ArrayList();

            CollectionNodeDeserializer.DeserializeHelper(itemType, parser, nestedObjectDeserializer, items, true);

            var array = Array.CreateInstance(itemType, items.Count);

            items.CopyTo(array, 0);

            value = array;
            return(true);
        }
        bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func <EventReader, Type, object> nestedObjectDeserializer, out object value)
        {
            if (!expectedType.IsArray)
            {
                value = false;
                return(false);
            }

            var itemType = expectedType.GetElementType();

            var items = new ArrayList();

            CollectionNodeDeserializer.DeserializeHelper(itemType, reader, expectedType, nestedObjectDeserializer, items, true);

            var array = Array.CreateInstance(itemType, items.Count);

            items.CopyTo(array, 0);

            value = array;
            return(true);
        }