Beispiel #1
0
        public override object ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
        {
            xmlReader.Read();
            Type   objType = UnderlyingType;
            object obj     = objType.IsArray ? Array.CreateInstance(objType.GetElementType(), 0) : GetUninitializedObject(objType);

            context.AddNewObject(obj);
            string            objectId = context.GetObjectId();
            SerializationInfo serInfo  = context.ReadSerializationInfo(xmlReader, objType);
            object            newObj   = SerializationSurrogateSetObjectData(obj, serInfo, context.GetStreamingContext());

            if (newObj == null)
            {
                newObj = obj;
            }
            if (newObj is IDeserializationCallback)
            {
                ((IDeserializationCallback)newObj).OnDeserialization(null);
            }
            if (newObj is IObjectReference)
            {
                newObj = GetRealObject((IObjectReference)newObj, context.GetStreamingContext());
            }
            context.ReplaceDeserializedObject(objectId, obj, newObj);
            xmlReader.ReadEndElement();
            return(newObj);
        }