Ejemplo n.º 1
0
        internal override object?ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext?context)
        {
            Debug.Assert(context != null);

            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()) ?? 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);
        }
        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            jsonReader.Read();
            object o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, MemberNames);

            jsonReader.ReadEndElement();
            return(o);
        }
Ejemplo n.º 3
0
        public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
        {
            jsonReader.Read();
            object obj2 = null;

            if (context.IsGetOnlyCollection)
            {
                context.IsGetOnlyCollection = false;
                this.JsonFormatGetOnlyReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, this.TraditionalCollectionDataContract);
            }
            else
            {
                obj2 = this.JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, this.TraditionalCollectionDataContract);
            }
            jsonReader.ReadEndElement();
            return(obj2);
        }
Ejemplo n.º 4
0
 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     jsonReader.Read();
     object o = null;
     if (context.IsGetOnlyCollection)
     {
         // IsGetOnlyCollection value has already been used to create current collectiondatacontract, value can now be reset. 
         context.IsGetOnlyCollection = false;
         JsonFormatGetOnlyReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, TraditionalCollectionDataContract);
     }
     else
     {
         o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, TraditionalCollectionDataContract);
     }
     jsonReader.ReadEndElement();
     return o;
 }
Ejemplo n.º 5
0
 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     jsonReader.Read();
     object o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, MemberNames);
     jsonReader.ReadEndElement();
     return o;
 }
Ejemplo n.º 6
0
 public override object ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
 {
     jsonReader.Read();
     object o = null;
     if (context.IsGetOnlyCollection)
     {
         // IsGetOnlyCollection value has already been used to create current collectiondatacontract, value can now be reset. 
         context.IsGetOnlyCollection = false;
         JsonFormatGetOnlyReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, TraditionalCollectionDataContract);
     }
     else
     {
         o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, JsonGlobals.itemDictionaryString, TraditionalCollectionDataContract);
     }
     jsonReader.ReadEndElement();
     return o;
 }