GetTypeReader() public method

public GetTypeReader ( Type targetType ) : Microsoft.Xna.Framework.Content.ContentTypeReader
targetType System.Type
return Microsoft.Xna.Framework.Content.ContentTypeReader
Exemplo n.º 1
0
 protected internal override void Initialize(ContentTypeReaderManager manager)
 {
     keyType     = typeof(TKey);
     valueType   = typeof(TValue);
     keyReader   = manager.GetTypeReader(keyType);
     valueReader = manager.GetTypeReader(valueType);
 }
Exemplo n.º 2
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
#if WEB
            elementReader = manager.GetTypeReader(typeof(T));
#else
            Type readerType = Enum.GetUnderlyingType(typeof(T));
            elementReader = manager.GetTypeReader(readerType);
#endif
        }
Exemplo n.º 3
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);

            Type baseType = TargetType.BaseType;

            if (baseType != null && baseType != typeof(object))
            {
                baseTypeReader = manager.GetTypeReader(baseType);
            }

            constructor = TargetType.GetDefaultConstructor();

            const BindingFlags attrs = (
                BindingFlags.NonPublic |
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.DeclaredOnly
                );

            /* Sometimes, overridden properties of abstract classes can show up even with
             * BindingFlags.DeclaredOnly is passed to GetProperties. Make sure that
             * all properties in this list are defined in this class by comparing
             * its get method with that of its base class. If they're the same
             * Then it's an overridden property.
             */
            PropertyInfo[] properties = TargetType.GetProperties(attrs);
            FieldInfo[]    fields     = TargetType.GetFields(attrs);
            readers = new List <ReadElement>(fields.Length + properties.Length);

            // Gather the properties.
            foreach (PropertyInfo property in properties)
            {
                MethodInfo pm = property.GetGetMethod(true);
                if (pm == null || pm != pm.GetBaseDefinition())
                {
                    continue;
                }

                ReadElement read = GetElementReader(manager, property);
                if (read != null)
                {
                    readers.Add(read);
                }
            }

            // Gather the fields.
            foreach (FieldInfo field in fields)
            {
                ReadElement read = GetElementReader(manager, field);
                if (read != null)
                {
                    readers.Add(read);
                }
            }
        }
Exemplo n.º 4
0
        public T ReadObject <T>(T existingInstance)
        {
            ContentTypeReader typeReader = typeReaderManager.GetTypeReader(typeof(T));

            if (typeReader != null)
            {
                return((T)typeReader.Read(this, existingInstance));
            }
            throw new ContentLoadException(String.Format("Could not read object type " + typeof(T).Name));
        }
Exemplo n.º 5
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);
            this.manager = manager;
            Type type = targetType.BaseType;

            if (type != null && type != typeof(object))
            {
                baseType       = type;
                baseTypeReader = manager.GetTypeReader(baseType);
            }
            constructor = targetType.GetDefaultConstructor();
            properties  = targetType.GetAllProperties();
            fields      = targetType.GetAllFields();
        }
Exemplo n.º 6
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);
            this.manager = manager;
            Type baseType = this.targetType.BaseType;

            if (baseType != (Type)null && baseType != typeof(object))
            {
                this.baseType       = baseType;
                this.baseTypeReader = manager.GetTypeReader(this.baseType);
            }
            this.constructor = ContentExtensions.GetDefaultConstructor(this.targetType);
            this.properties  = ContentExtensions.GetAllProperties(this.targetType);
            this.fields      = ContentExtensions.GetAllFields(this.targetType);
        }
Exemplo n.º 7
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);
            this.manager = manager;

            if (targetType.BaseType != null && targetType.BaseType != typeof(object))
            {
                baseType       = targetType.BaseType;
                baseTypeReader = manager.GetTypeReader(baseType);
            }

            BindingFlags attrs = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;

            constructor = targetType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null);
            properties  = targetType.GetProperties(attrs);
            fields      = targetType.GetFields(attrs);
        }
Exemplo n.º 8
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);

            var baseType = ReflectionHelpers.GetBaseType(TargetType);

            if (baseType != null && baseType != typeof(object))
            {
                _baseTypeReader = manager.GetTypeReader(baseType);
            }

            _constructor = TargetType.GetDefaultConstructor();

            var properties = TargetType.GetAllProperties();
            var fields     = TargetType.GetAllFields();

            _readers = new List <ReadElement>(fields.Length + properties.Length);

            // Gather the properties.
            foreach (var property in properties)
            {
                var read = GetElementReader(manager, property);
                if (read != null)
                {
                    _readers.Add(read);
                }
            }

            // Gather the fields.
            foreach (var field in fields)
            {
                var read = GetElementReader(manager, field);
                if (read != null)
                {
                    _readers.Add(read);
                }
            }
        }
Exemplo n.º 9
0
        public object ReadAsset <T>()
        {
            if (Version < 6)
            {
                // Transistor: Skip old unused resource loader deets. Used to call ContentReaderManager here.
                int num = Read7BitEncodedInt();
                for (int i = 0; i < num; i++)
                {
                    ReadString();
                    ReadInt32();
                }
                Read7BitEncodedInt();
                Read7BitEncodedInt();

                if (typeof(T) != typeof(Texture))
                {
                    throw new Exception("Only textures are supported for the version 5 format.");
                }
            }

            // Use the content type reader for the requested type directly.
            return(ContentTypeReaderManager.GetTypeReader(typeof(T)).Read(this));
        }
Exemplo n.º 10
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);

            Type baseType = TargetType.BaseType;

            if (baseType != null && baseType != typeof(object))
            {
                baseTypeReader = manager.GetTypeReader(baseType);
            }

            constructor = TargetType.GetDefaultConstructor();

            PropertyInfo[] properties = TargetType.GetAllProperties();
            FieldInfo[]    fields     = TargetType.GetAllFields();
            readers = new List <ReadElement>(fields.Length + properties.Length);

            // Gather the properties.
            foreach (PropertyInfo property in properties)
            {
                ReadElement read = GetElementReader(manager, property);
                if (read != null)
                {
                    readers.Add(read);
                }
            }

            // Gather the fields.
            foreach (FieldInfo field in fields)
            {
                ReadElement read = GetElementReader(manager, field);
                if (read != null)
                {
                    readers.Add(read);
                }
            }
        }
Exemplo n.º 11
0
        private void Read(object parent, ContentReader input, MemberInfo member)
        {
            PropertyInfo property = member as PropertyInfo;
            FieldInfo    field    = member as FieldInfo;

            // properties must have public get and set
            if (property != null && (property.CanWrite == false || property.CanRead == false))
            {
                return;
            }

            if (property != null && property.Name == "Item")
            {
#if WINRT
                var getMethod = property.GetMethod;
                var setMethod = property.SetMethod;
#else
                var getMethod = property.GetGetMethod();
                var setMethod = property.GetSetMethod();
#endif

                if ((getMethod != null && getMethod.GetParameters().Length > 0) ||
                    (setMethod != null && setMethod.GetParameters().Length > 0))
                {
                    /*
                     * This is presumably a property like this[indexer] and this
                     * should not get involved in the object deserialization
                     * */
                    return;
                }
            }
#if WINRT
            Attribute attr = member.GetCustomAttribute(typeof(ContentSerializerIgnoreAttribute));
#else
            Attribute attr = Attribute.GetCustomAttribute(member, typeof(ContentSerializerIgnoreAttribute));
#endif
            if (attr != null)
            {
                return;
            }
#if WINRT
            Attribute attr2 = member.GetCustomAttribute(typeof(ContentSerializerAttribute));
#else
            Attribute attr2 = Attribute.GetCustomAttribute(member, typeof(ContentSerializerAttribute));
#endif
            bool isSharedResource = false;
            if (attr2 != null)
            {
                var cs = attr2 as ContentSerializerAttribute;
                isSharedResource = cs.SharedResource;
            }
            else
            {
                if (property != null)
                {
#if WINRT
                    if (property.GetMethod != null && !property.GetMethod.IsPublic)
                    {
                        return;
                    }
                    if (property.SetMethod != null && !property.SetMethod.IsPublic)
                    {
                        return;
                    }
#else
                    foreach (MethodInfo info in property.GetAccessors(true))
                    {
                        if (info.IsPublic == false)
                        {
                            return;
                        }
                    }
#endif
                }
                else
                {
                    if (!field.IsPublic)
                    {
                        return;
                    }
                }
            }
            ContentTypeReader reader = null;

            Type elementType = null;

            if (property != null)
            {
                reader = manager.GetTypeReader(elementType = property.PropertyType);
            }
            else
            {
                reader = manager.GetTypeReader(elementType = field.FieldType);
            }
            if (!isSharedResource)
            {
                object existingChildObject = CreateChildObject(property, field);
                object obj2;

                if (reader == null && elementType == typeof(object))
                {
                    /* Reading elements serialized as "object" */
                    obj2 = input.ReadObject <object>();
                }
                else
                {
                    /* Default */
                    obj2 = input.ReadObject(reader, existingChildObject);
                }

                if (property != null)
                {
                    property.SetValue(parent, obj2, null);
                }
                else
                {
                    // Private fields can be serialized if they have ContentSerializerAttribute added to them
                    if (field.IsPrivate == false || attr2 != null)
                    {
                        field.SetValue(parent, obj2);
                    }
                }
            }
            else
            {
                Action <object> action = delegate(object value)
                {
                    if (property != null)
                    {
                        property.SetValue(parent, value, null);
                    }
                    else
                    {
                        field.SetValue(parent, value);
                    }
                };
                input.ReadSharedResource(action);
            }
        }
Exemplo n.º 12
0
        private static ReadElement GetElementReader(
            ContentTypeReaderManager manager,
            MemberInfo member
            )
        {
            PropertyInfo property = member as PropertyInfo;
            FieldInfo    field    = member as FieldInfo;

            if (property != null)
            {
                // Properties must have at least a getter.
                if (property.CanRead == false)
                {
                    return(null);
                }

                // Skip over indexer properties
                if (property.GetIndexParameters().Length > 0)
                {
                    return(null);
                }
            }

            // Are we explicitly asked to ignore this item?
            Attribute attr = Attribute.GetCustomAttribute(
                member,
                typeof(ContentSerializerIgnoreAttribute)
                );

            if (attr != null)
            {
                return(null);
            }

            ContentSerializerAttribute contentSerializerAttribute = Attribute.GetCustomAttribute(
                member,
                typeof(ContentSerializerAttribute)
                ) as ContentSerializerAttribute;

            if (contentSerializerAttribute == null)
            {
                if (property != null)
                {
                    /* There is no ContentSerializerAttribute, so non-public
                     * properties cannot be deserialized.
                     */
                    MethodInfo getMethod = property.GetGetMethod(true);
                    if (getMethod != null && !getMethod.IsPublic)
                    {
                        return(null);
                    }
                    MethodInfo setMethod = property.GetSetMethod(true);
                    if (setMethod != null && !setMethod.IsPublic)
                    {
                        return(null);
                    }

                    /* If the read-only property has a type reader,
                     * and CanDeserializeIntoExistingObject is true,
                     * then it is safe to deserialize into the existing object.
                     */
                    if (!property.CanWrite)
                    {
                        ContentTypeReader typeReader = manager.GetTypeReader(property.PropertyType);
                        if (typeReader == null || !typeReader.CanDeserializeIntoExistingObject)
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    /* There is no ContentSerializerAttribute, so non-public
                     * fields cannot be deserialized.
                     */
                    if (!field.IsPublic)
                    {
                        return(null);
                    }

                    // evolutional: Added check to skip initialise only fields
                    if (field.IsInitOnly)
                    {
                        return(null);
                    }
                }
            }

            Action <object, object> setter;
            Type elementType;

            if (property != null)
            {
                elementType = property.PropertyType;
                if (property.CanWrite)
                {
                    setter = (o, v) => property.SetValue(o, v, null);
                }
                else
                {
                    setter = (o, v) => { };
                }
            }
            else
            {
                elementType = field.FieldType;
                setter      = field.SetValue;
            }

            if (contentSerializerAttribute != null &&
                contentSerializerAttribute.SharedResource)
            {
                return((input, parent) =>
                {
                    Action <object> action = value => setter(parent, value);
                    input.ReadSharedResource(action);
                });
            }

            // We need to have a reader at this point.
            ContentTypeReader reader = manager.GetTypeReader(elementType);

            if (reader == null)
            {
                throw new ContentLoadException(string.Format(
                                                   "Content reader could not be found for {0} type.",
                                                   elementType.FullName
                                                   ));
            }

            /* We use the construct delegate to pick the correct existing
             * object to be the target of deserialization.
             */
            Func <object, object> construct = parent => null;

            if (property != null && !property.CanWrite)
            {
                construct = parent => property.GetValue(parent, null);
            }

            return((input, parent) =>
            {
                object existing = construct(parent);
                object obj2 = input.ReadObject(reader, existing);
                setter(parent, obj2);
            });
        }
Exemplo n.º 13
0
        private static ReadElement GetElementReader(ContentTypeReaderManager manager, MemberInfo member)
        {
            var property = member as PropertyInfo;
            var field    = member as FieldInfo;

            Debug.Assert(field != null || property != null);

            if (property != null)
            {
                // Properties must have at least a getter.
                if (property.CanRead == false)
                {
                    return(null);
                }

                // Skip over indexer properties.
                if (property.GetIndexParameters().Any())
                {
                    return(null);
                }
            }

            // Are we explicitly asked to ignore this item?
            if (ReflectionHelpers.GetCustomAttribute <ContentSerializerIgnoreAttribute>(member) != null)
            {
                return(null);
            }

            var contentSerializerAttribute = ReflectionHelpers.GetCustomAttribute <ContentSerializerAttribute>(member);

            if (contentSerializerAttribute == null)
            {
                if (property != null)
                {
                    // There is no ContentSerializerAttribute, so non-public
                    // properties cannot be deserialized.
                    if (!ReflectionHelpers.PropertyIsPublic(property))
                    {
                        return(null);
                    }

                    // If the read-only property has a type reader,
                    // and CanDeserializeIntoExistingObject is true,
                    // then it is safe to deserialize into the existing object.
                    if (!property.CanWrite)
                    {
                        var typeReader = manager.GetTypeReader(property.PropertyType);
                        if (typeReader == null || !typeReader.CanDeserializeIntoExistingObject)
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    // There is no ContentSerializerAttribute, so non-public
                    // fields cannot be deserialized.
                    if (!field.IsPublic)
                    {
                        return(null);
                    }

                    // evolutional: Added check to skip initialise only fields
                    if (field.IsInitOnly)
                    {
                        return(null);
                    }
                }
            }

            Action <object, object> setter;
            Type elementType;

            if (property != null)
            {
                elementType = property.PropertyType;
                if (property.CanWrite)
                {
                    setter = (o, v) => property.SetValue(o, v, null);
                }
                else
                {
                    setter = (o, v) => { }
                };
            }
            else
            {
                elementType = field.FieldType;
                setter      = field.SetValue;
            }

            // Shared resources get special treatment.
            if (contentSerializerAttribute != null && contentSerializerAttribute.SharedResource)
            {
                return((input, parent) =>
                {
                    Action <object> action = value => setter(parent, value);
                    input.ReadSharedResource(action);
                });
            }

            // We need to have a reader at this point.
            var reader = manager.GetTypeReader(elementType);

            if (reader == null)
            {
                if (elementType == typeof(System.Array))
                {
                    reader = new ArrayReader <Array>();
                }
                else
                {
                    throw new ContentLoadException(string.Format("Content reader could not be found for {0} type.", elementType.FullName));
                }
            }

            // We use the construct delegate to pick the correct existing
            // object to be the target of deserialization.
            Func <object, object> construct = parent => null;

            if (property != null && !property.CanWrite)
            {
                construct = parent => property.GetValue(parent, null);
            }

            return((input, parent) =>
            {
                var existing = construct(parent);
                var obj2 = input.ReadObject(reader, existing);
                setter(parent, obj2);
            });
        }
Exemplo n.º 14
0
        private void Read(object parent, ContentReader input, MemberInfo member)
        {
            PropertyInfo property = member as PropertyInfo;
            FieldInfo    field    = member as FieldInfo;

            if (property != null && property.CanWrite == false)
            {
                return;
            }
            Attribute attr = Attribute.GetCustomAttribute(member, typeof(ContentSerializerIgnoreAttribute));

            if (attr != null)
            {
                return;
            }
            Attribute attr2            = Attribute.GetCustomAttribute(member, typeof(ContentSerializerAttribute));
            bool      isSharedResource = false;

            if (attr2 != null)
            {
                var cs = attr2 as ContentSerializerAttribute;
                isSharedResource = cs.SharedResource;
            }
            else
            {
                if (property != null)
                {
                    foreach (MethodInfo info in property.GetAccessors(true))
                    {
                        if (info.IsPublic == false)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (!field.IsPublic)
                    {
                        return;
                    }
                }
            }
            ContentTypeReader reader = null;

            if (property != null)
            {
                reader = manager.GetTypeReader(property.PropertyType);
            }
            else
            {
                reader = manager.GetTypeReader(field.FieldType);
            }
            if (!isSharedResource)
            {
                object existingChildObject = CreateChildObject(property, field);
                object obj2 = null;

                obj2 = input.ReadObject <object>(reader, existingChildObject);

                if (property != null)
                {
                    property.SetValue(parent, obj2, null);
                }
                else
                {
                    if (field.IsPrivate == false)
                    {
                        field.SetValue(parent, obj2);
                    }
                }
            }
            else
            {
                Action <object> action = delegate(object value)
                {
                    if (property != null)
                    {
                        property.SetValue(parent, value, null);
                    }
                    else
                    {
                        field.SetValue(parent, value);
                    }
                };
                input.ReadSharedResource <object>(action);
            }
        }
Exemplo n.º 15
0
        private void Read(
            object parent,
            ContentReader input,
            MemberInfo member
            )
        {
            PropertyInfo property = member as PropertyInfo;
            FieldInfo    field    = member as FieldInfo;

            // Properties must have public get and set
            if (property != null &&
                (property.CanWrite == false ||
                 property.CanRead == false))
            {
                return;
            }

            if (property != null && property.Name == "Item")
            {
                MethodInfo getMethod = property.GetGetMethod();
                MethodInfo setMethod = property.GetSetMethod();

                if ((getMethod != null && getMethod.GetParameters().Length > 0) ||
                    (setMethod != null && setMethod.GetParameters().Length > 0))
                {
                    /* This is presumably a property like this[indexer] and this
                     * should not get involved in the object deserialization
                     */
                    return;
                }
            }
            Attribute attr = Attribute.GetCustomAttribute(member, typeof(ContentSerializerIgnoreAttribute));

            if (attr != null)
            {
                return;
            }
            Attribute attr2            = Attribute.GetCustomAttribute(member, typeof(ContentSerializerAttribute));
            bool      isSharedResource = false;

            if (attr2 != null)
            {
                ContentSerializerAttribute cs = attr2 as ContentSerializerAttribute;
                isSharedResource = cs.SharedResource;
            }
            else
            {
                if (property != null)
                {
                    foreach (MethodInfo info in property.GetAccessors(true))
                    {
                        if (info.IsPublic == false)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (!field.IsPublic)
                    {
                        return;
                    }

                    // Evolutional: Added check to skip initialise only fields
                    if (field.IsInitOnly)
                    {
                        return;
                    }
                }
            }
            ContentTypeReader reader = null;
            Type elementType         = null;

            if (property != null)
            {
                reader = manager.GetTypeReader(elementType = property.PropertyType);
            }
            else
            {
                reader = manager.GetTypeReader(elementType = field.FieldType);
            }
            if (!isSharedResource)
            {
                object existingChildObject = CreateChildObject(property, field);
                object obj2;
                if (reader == null && elementType == typeof(object))
                {
                    // Reading elements serialized as "object"
                    obj2 = input.ReadObject <object>();
                }
                else
                {
                    // Default

                    /* Evolutional: Fix. We can get here and still be NULL,
                     * exit gracefully
                     */
                    if (reader == null)
                    {
                        return;
                    }
                    obj2 = input.ReadObject(reader, existingChildObject);
                }
                if (property != null)
                {
                    property.SetValue(parent, obj2, null);
                }
                else
                {
                    /* Private fields can be serialized if they have
                     * ContentSerializerAttribute added to them
                     */
                    if (field.IsPrivate == false || attr2 != null)
                    {
                        field.SetValue(parent, obj2);
                    }
                }
            }
            else
            {
                Action <object> action = delegate(object value)
                {
                    if (property != null)
                    {
                        property.SetValue(parent, value, null);
                    }
                    else
                    {
                        field.SetValue(parent, value);
                    }
                };
                input.ReadSharedResource(action);
            }
        }
Exemplo n.º 16
0
        private static ReadElement GetElementReader(ContentTypeReaderManager manager, MemberInfo member)
        {
            var property = member as PropertyInfo;
            var field    = member as FieldInfo;

            // properties must have public get and set
            if (property != null && (property.CanWrite == false || property.CanRead == false))
            {
                return(null);
            }

            if (property != null && property.Name == "Item")
            {
                var getMethod = ReflectionHelpers.GetPropertyGetMethod(property);
                var setMethod = ReflectionHelpers.GetPropertySetMethod(property);

                if ((getMethod != null && getMethod.GetParameters().Length > 0) ||
                    (setMethod != null && setMethod.GetParameters().Length > 0))
                {
                    /*
                     * This is presumably a property like this[indexer] and this
                     * should not get involved in the object deserialization
                     * */
                    return(null);
                }
            }

            var attr = ReflectionHelpers.GetCustomAttribute(member, typeof(ContentSerializerIgnoreAttribute));

            if (attr != null)
            {
                return(null);
            }

            var contentSerializerAttribute =
                ReflectionHelpers.GetCustomAttribute(member, typeof(ContentSerializerAttribute)) as
                ContentSerializerAttribute;

            var isSharedResource = false;

            if (contentSerializerAttribute != null)
            {
                isSharedResource = contentSerializerAttribute.SharedResource;
            }
            else
            {
                if (property != null)
                {
                    if (!ReflectionHelpers.PropertyIsPublic(property))
                    {
                        return(null);
                    }
                }
                else
                {
                    if (!field.IsPublic)
                    {
                        return(null);
                    }

                    // evolutional: Added check to skip initialise only fields
                    if (field.IsInitOnly)
                    {
                        return(null);
                    }

                    // Private fields can be serialized if they have ContentSerializerAttribute added to them
                    if (field.IsPrivate && contentSerializerAttribute == null)
                    {
                        return(null);
                    }
                }
            }

            Action <object, object> setter;
            ContentTypeReader       reader;
            Type elementType;

            if (property != null)
            {
                elementType = property.PropertyType;
                reader      = manager.GetTypeReader(property.PropertyType);
                setter      = (o, v) => property.SetValue(o, v, null);
            }
            else
            {
                elementType = field.FieldType;
                reader      = manager.GetTypeReader(field.FieldType);
                setter      = field.SetValue;
            }

            if (isSharedResource)
            {
                return((input, parent) =>
                {
                    Action <object> action = value => setter(parent, value);
                    input.ReadSharedResource(action);
                });
            }

            Func <object> construct = () => null;

            if (ReflectionHelpers.IsConcreteClass(elementType))
            {
                var constructor = elementType.GetDefaultConstructor();
                if (constructor != null)
                {
                    construct = () => constructor.Invoke(null);
                }
            }

            // Reading elements serialized as "object".
            if (reader == null && elementType == typeof(object))
            {
                return((input, parent) =>
                {
                    var obj2 = input.ReadObject <object>();
                    setter(parent, obj2);
                });
            }

            // evolutional: Fix. We can get here and still be NULL, exit gracefully
            if (reader == null)
            {
                return(null);
            }

            return((input, parent) =>
            {
                var existing = construct();
                var obj2 = input.ReadObject(reader, existing);
                setter(parent, obj2);
            });
        }
Exemplo n.º 17
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            Type readerType = typeof(T);

            elementReader = manager.GetTypeReader(readerType);
        }
Exemplo n.º 18
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            Type underlyingType = Enum.GetUnderlyingType(typeof(T));

            this.elementReader = manager.GetTypeReader(underlyingType);
        }