public override bool TryResolveType(Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace) { if (type == null) { typeName = null; typeNamespace = null; return(false); } if (declaredType != null && declaredType.IsInterface && CollectionDataContract.IsCollectionInterface(declaredType)) { typeName = null; typeNamespace = null; return(true); } DataContract contract = DataContract.GetDataContract(type); if (_context.IsKnownType(contract, contract.KnownDataContracts, declaredType)) { typeName = contract.Name; typeNamespace = contract.Namespace; return(true); } else { typeName = null; typeNamespace = null; return(false); } }
private void Initialize( Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver, bool serializeReadOnlyTypes) { _rootType = type ?? throw new ArgumentNullException(nameof(type)); if (knownTypes != null) { knownTypeList = new List <Type>(); foreach (Type knownType in knownTypes) { knownTypeList.Add(knownType); } } if (maxItemsInObjectGraph < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(maxItemsInObjectGraph), SR.ValueMustBeNonNegative)); } this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.preserveObjectReferences = preserveObjectReferences; this.dataContractSurrogate = dataContractSurrogate; this.dataContractResolver = dataContractResolver; this.serializeReadOnlyTypes = serializeReadOnlyTypes; }
internal void InternalWriteObjectContent(XmlWriterDelegator writer, object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) { if (this.MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph }))); } DataContract rootContract = this.RootContract; Type underlyingType = rootContract.UnderlyingType; Type objType = (graph == null) ? underlyingType : graph.GetType(); if (this.dataContractSurrogate != null) { graph = SurrogateToDataContractType(this.dataContractSurrogate, graph, underlyingType, ref objType); } if (dataContractResolver == null) { dataContractResolver = this.DataContractResolver; } if (graph == null) { if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeNull", new object[] { underlyingType }))); } XmlObjectSerializer.WriteNull(writer); } else if (underlyingType == objType) { if (rootContract.CanContainReferences) { XmlObjectSerializerWriteContext context = XmlObjectSerializerWriteContext.CreateContext(this, rootContract, dataContractResolver); context.HandleGraphAtTopLevel(writer, graph, rootContract); context.SerializeWithoutXsiType(rootContract, writer, graph, underlyingType.TypeHandle); } else { rootContract.WriteXmlValue(writer, graph, null); } } else { XmlObjectSerializerWriteContext context2 = null; if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeSerializedAsDerivedType", new object[] { objType, rootContract.UnderlyingType }))); } rootContract = GetDataContract(rootContract, underlyingType, objType); context2 = XmlObjectSerializerWriteContext.CreateContext(this, this.RootContract, dataContractResolver); if (rootContract.CanContainReferences) { context2.HandleGraphAtTopLevel(writer, graph, rootContract); } context2.OnHandleIsReference(writer, rootContract, graph); context2.SerializeWithXsiTypeAtTopLevel(rootContract, writer, graph, underlyingType.TypeHandle, objType); } }
internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, System.Runtime.Serialization.DataContractResolver dataContractResolver) { this.scopedKnownTypes = new ScopedKnownTypes(); this.serializer = serializer; this.itemCount = 1; this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.streamingContext = streamingContext; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.dataContractResolver = dataContractResolver; }
public DataContractSerializer(Type type, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) { Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, false); }
internal XmlObjectSerializerReadContextComplex( DataContractSerializer serializer, DataContract rootTypeDataContract, System.Runtime.Serialization.DataContractResolver dataContractResolver) : base(serializer, rootTypeDataContract, dataContractResolver) { mode = SerializationMode.SharedContract; preserveObjectReferences = serializer.PreserveObjectReferences; dataContractSurrogate = serializer.DataContractSurrogate; }
protected XmlObjectSerializerWriteContext( DataContractSerializer serializer, DataContract rootTypeDataContract, System.Runtime.Serialization.DataContractResolver resolver) : base(serializer, rootTypeDataContract, resolver) { serializeReadOnlyTypes = serializer.SerializeReadOnlyTypes; // Known types restricts the set of types that can be deserialized unsafeTypeForwardingEnabled = true; }
internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, System.Runtime.Serialization.DataContractResolver dataContractResolver) { this.scopedKnownTypes = new ScopedKnownTypes(); this.serializer = serializer; this.itemCount = 1; this.maxItemsInObjectGraph = maxItemsInObjectGraph; this.streamingContext = streamingContext; this.ignoreExtensionDataObject = ignoreExtensionDataObject; this.dataContractResolver = dataContractResolver; }
public DataContractSerializer(Type type, string rootName, string rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver) { XmlDictionary dictionary = new XmlDictionary(2); Initialize(type, dictionary.Add(rootName), dictionary.Add(DataContract.GetNamespace(rootNamespace)), knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, false); }
internal override object InternalReadObject(XmlReaderDelegator xmlReader, bool verifyObjectName, DataContractResolver dataContractResolver) { if (MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.ExceededMaxItemsQuota, MaxItemsInObjectGraph))); } if (dataContractResolver == null) { dataContractResolver = DataContractResolver; } if (verifyObjectName) { if (!InternalIsStartObject(xmlReader)) { XmlDictionaryString expectedName; XmlDictionaryString expectedNs; if (rootName == null) { expectedName = RootContract.TopLevelElementName; expectedNs = RootContract.TopLevelElementNamespace; } else { expectedName = rootName; expectedNs = rootNamespace; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(SR.Format(SR.ExpectingElement, expectedNs, expectedName), xmlReader)); } } else if (!IsStartElement(xmlReader)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(SR.Format(SR.ExpectingElementAtDeserialize, XmlNodeType.Element), xmlReader)); } DataContract contract = RootContract; if (contract.IsPrimitive && object.ReferenceEquals(contract.UnderlyingType, _rootType) /*handle Nullable<T> differently*/) { return(contract.ReadXmlValue(xmlReader, null)); } if (IsRootXmlAny(rootName, contract)) { return(XmlObjectSerializerReadContext.ReadRootIXmlSerializable(xmlReader, contract as XmlDataContract, false /*isMemberType*/)); } XmlObjectSerializerReadContext context = XmlObjectSerializerReadContext.CreateContext(this, contract, dataContractResolver); return(context.InternalDeserialize(xmlReader, _rootType, contract, null, null)); }
internal XmlObjectSerializerContext( DataContractSerializer serializer, DataContract rootTypeDataContract, System.Runtime.Serialization.DataContractResolver dataContractResolver) : this(serializer, serializer.MaxItemsInObjectGraph, new System.Runtime.Serialization.StreamingContext(System.Runtime.Serialization.StreamingContextStates.All), serializer.IgnoreExtensionDataObject, dataContractResolver) { this.rootTypeDataContract = rootTypeDataContract; serializerKnownTypeList = serializer.knownTypeList; }
private void Initialize(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable <Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, DataContractResolver dataContractResolver, bool serializeReadOnlyTypes) { Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate, dataContractResolver, serializeReadOnlyTypes); // validate root name and namespace are both non-null this.rootName = rootName; this.rootNamespace = rootNamespace; }
/// <summary> /// Resolves a type by name. /// Gets called by the WCF framework when deserializing. /// </summary> /// <param name="typeName"></param> /// <param name="typeNamespace"></param> /// <param name="declaredType"></param> /// <param name="knownTypeResolver"></param> /// <returns></returns> public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver) { try { return(KnownTypeResolver.ResolveType(Encoder.SafeDecode(typeName)) ?? (KnownTypeResolver.IsKnownType(declaredType) ? declaredType : knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, DummyDataContractResolver))); } catch (Exception ex) { Log.Error(ex); throw; } }
internal override object InternalReadObject(XmlReaderDelegator xmlReader, bool verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) { if (this.MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph }))); } if (dataContractResolver == null) { dataContractResolver = this.DataContractResolver; } if (verifyObjectName) { if (!this.InternalIsStartObject(xmlReader)) { XmlDictionaryString topLevelElementName; XmlDictionaryString topLevelElementNamespace; if (this.rootName == null) { topLevelElementName = this.RootContract.TopLevelElementName; topLevelElementNamespace = this.RootContract.TopLevelElementNamespace; } else { topLevelElementName = this.rootName; topLevelElementNamespace = this.rootNamespace; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(System.Runtime.Serialization.SR.GetString("ExpectingElement", new object[] { topLevelElementNamespace, topLevelElementName }), xmlReader)); } } else if (!base.IsStartElement(xmlReader)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(System.Runtime.Serialization.SR.GetString("ExpectingElementAtDeserialize", new object[] { XmlNodeType.Element }), xmlReader)); } DataContract rootContract = this.RootContract; if (rootContract.IsPrimitive && object.ReferenceEquals(rootContract.UnderlyingType, this.rootType)) { return(rootContract.ReadXmlValue(xmlReader, null)); } if (base.IsRootXmlAny(this.rootName, rootContract)) { return(XmlObjectSerializerReadContext.ReadRootIXmlSerializable(xmlReader, rootContract as XmlDataContract, false)); } return(XmlObjectSerializerReadContext.CreateContext(this, rootContract, dataContractResolver).InternalDeserialize(xmlReader, this.rootType, rootContract, null, null)); }
/// <summary> /// Checks if type is considered a known type. /// Gets called by the WCF framework when serializing. /// </summary> /// <param name="type"></param> /// <param name="declaredType"></param> /// <param name="knownTypeResolver"></param> /// <param name="typeName"></param> /// <param name="typeNamespace"></param> /// <returns></returns> public override bool TryResolveType(Type type, Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver, out XmlDictionaryString typeName, out XmlDictionaryString typeNamespace) { try { if (!KnownTypeResolver.IsKnownType(type)) { return(knownTypeResolver.TryResolveType(type, declaredType, DummyDataContractResolver, out typeName, out typeNamespace)); } XmlDictionary dictionary = new XmlDictionary(); typeName = dictionary.Add(Encoder.SafeEncode(type.AssemblyQualifiedName())); typeNamespace = dictionary.Add("http://p2p.com"); return(true); } catch (Exception ex) { Log.Error(ex); throw; } }
internal static XmlObjectSerializerWriteContext CreateContext(DataContractSerializer serializer, DataContract rootTypeDataContract, System.Runtime.Serialization.DataContractResolver dataContractResolver) { return((serializer.PreserveObjectReferences || serializer.DataContractSurrogate != null) ? new XmlObjectSerializerWriteContextComplex(serializer, rootTypeDataContract, dataContractResolver) : new XmlObjectSerializerWriteContext(serializer, rootTypeDataContract, dataContractResolver)); }
public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver) { return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? Type.GetType(typeName + ", " + typeNamespace)); }
internal object ReadObjectHandleExceptions(XmlReaderDelegator reader, bool verifyObjectName, DataContractResolver dataContractResolver) { try { reader = reader ?? throw new ArgumentNullException(nameof(reader)); return(InternalReadObject(reader, verifyObjectName, dataContractResolver)); } catch (XmlException ex) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorDeserializing, GetDeserializeType(), ex), ex)); } catch (FormatException ex) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorDeserializing, GetDeserializeType(), ex), ex)); } }
public abstract System.Type ResolveName(string typeName, string typeNamespace, System.Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver);
public object ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) { throw null; }
public object ReadObject(XmlDictionaryReader reader, bool verifyObjectName, DataContractResolver dataContractResolver) { return(ReadObjectHandleExceptions(new XmlReaderDelegator(reader), verifyObjectName, dataContractResolver)); }
public void WriteObject(XmlDictionaryWriter writer, object graph, DataContractResolver dataContractResolver) { WriteObjectHandleExceptions(new XmlWriterDelegator(writer), graph, dataContractResolver); }
internal override void InternalWriteObject(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver) { InternalWriteStartObject(writer, graph); InternalWriteObjectContent(writer, graph, dataContractResolver); InternalWriteEndObject(writer); }
internal void InternalWriteObjectContent(XmlWriterDelegator writer, object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) { if (this.MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph }))); } DataContract rootContract = this.RootContract; Type underlyingType = rootContract.UnderlyingType; Type objType = (graph == null) ? underlyingType : graph.GetType(); if (this.dataContractSurrogate != null) { graph = SurrogateToDataContractType(this.dataContractSurrogate, graph, underlyingType, ref objType); } if (dataContractResolver == null) { dataContractResolver = this.DataContractResolver; } if (graph == null) { if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeNull", new object[] { underlyingType }))); } XmlObjectSerializer.WriteNull(writer); } else if (underlyingType == objType) { if (rootContract.CanContainReferences) { XmlObjectSerializerWriteContext context = XmlObjectSerializerWriteContext.CreateContext(this, rootContract, dataContractResolver); context.HandleGraphAtTopLevel(writer, graph, rootContract); context.SerializeWithoutXsiType(rootContract, writer, graph, underlyingType.TypeHandle); } else { rootContract.WriteXmlValue(writer, graph, null); } } else { XmlObjectSerializerWriteContext context2 = null; if (base.IsRootXmlAny(this.rootName, rootContract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("IsAnyCannotBeSerializedAsDerivedType", new object[] { objType, rootContract.UnderlyingType }))); } rootContract = GetDataContract(rootContract, underlyingType, objType); context2 = XmlObjectSerializerWriteContext.CreateContext(this, this.RootContract, dataContractResolver); if (rootContract.CanContainReferences) { context2.HandleGraphAtTopLevel(writer, graph, rootContract); } context2.OnHandleIsReference(writer, rootContract, graph); context2.SerializeWithXsiTypeAtTopLevel(rootContract, writer, graph, underlyingType.TypeHandle, objType); } }
public DataContractSerializer(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace, IEnumerable<Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, System.Runtime.Serialization.DataContractResolver dataContractResolver) : this(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, dataContractSurrogate) { this.dataContractResolver = dataContractResolver; }
internal virtual void InternalWriteObject(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver) { InternalWriteObject(writer, graph); }
internal void WriteObjectHandleExceptions(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver) { try { writer = writer ?? throw new ArgumentNullException(nameof(writer)); InternalWriteObject(writer, graph, dataContractResolver); } catch (XmlException ex) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex)); } catch (FormatException ex) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex)); } }
internal void InternalWriteObjectContent(XmlWriterDelegator writer, object graph, DataContractResolver dataContractResolver) { if (MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.ExceededMaxItemsQuota, MaxItemsInObjectGraph))); } DataContract contract = RootContract; Type declaredType = contract.UnderlyingType; Type graphType = (graph == null) ? declaredType : graph.GetType(); if (dataContractSurrogate != null) { graph = SurrogateToDataContractType(dataContractSurrogate, graph, declaredType, ref graphType); } if (dataContractResolver == null) { dataContractResolver = DataContractResolver; } if (graph == null) { if (IsRootXmlAny(rootName, contract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.IsAnyCannotBeNull, declaredType))); } WriteNull(writer); } else { if (declaredType == graphType) { if (contract.CanContainReferences) { XmlObjectSerializerWriteContext context = XmlObjectSerializerWriteContext.CreateContext(this, contract, dataContractResolver); context.HandleGraphAtTopLevel(writer, graph, contract); context.SerializeWithoutXsiType(contract, writer, graph, declaredType.TypeHandle); } else { contract.WriteXmlValue(writer, graph, null); } } else { XmlObjectSerializerWriteContext context = null; if (IsRootXmlAny(rootName, contract)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.IsAnyCannotBeSerializedAsDerivedType, graphType, contract.UnderlyingType))); } contract = GetDataContract(contract, declaredType, graphType); context = XmlObjectSerializerWriteContext.CreateContext(this, RootContract, dataContractResolver); if (contract.CanContainReferences) { context.HandleGraphAtTopLevel(writer, graph, contract); } context.OnHandleIsReference(writer, contract, graph); context.SerializeWithXsiTypeAtTopLevel(contract, writer, graph, declaredType.TypeHandle, graphType); } } }
public DataContractSerializer(System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, System.Collections.Generic.IEnumerable <System.Type> knownTypes, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, bool preserveObjectReferences, System.Runtime.Serialization.DataContractResolver dataContractResolver) { }
internal override object InternalReadObject(XmlReaderDelegator xmlReader, bool verifyObjectName, System.Runtime.Serialization.DataContractResolver dataContractResolver) { if (this.MaxItemsInObjectGraph == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("ExceededMaxItemsQuota", new object[] { this.MaxItemsInObjectGraph }))); } if (dataContractResolver == null) { dataContractResolver = this.DataContractResolver; } if (verifyObjectName) { if (!this.InternalIsStartObject(xmlReader)) { XmlDictionaryString topLevelElementName; XmlDictionaryString topLevelElementNamespace; if (this.rootName == null) { topLevelElementName = this.RootContract.TopLevelElementName; topLevelElementNamespace = this.RootContract.TopLevelElementNamespace; } else { topLevelElementName = this.rootName; topLevelElementNamespace = this.rootNamespace; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(System.Runtime.Serialization.SR.GetString("ExpectingElement", new object[] { topLevelElementNamespace, topLevelElementName }), xmlReader)); } } else if (!base.IsStartElement(xmlReader)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationExceptionWithReaderDetails(System.Runtime.Serialization.SR.GetString("ExpectingElementAtDeserialize", new object[] { XmlNodeType.Element }), xmlReader)); } DataContract rootContract = this.RootContract; if (rootContract.IsPrimitive && object.ReferenceEquals(rootContract.UnderlyingType, this.rootType)) { return rootContract.ReadXmlValue(xmlReader, null); } if (base.IsRootXmlAny(this.rootName, rootContract)) { return XmlObjectSerializerReadContext.ReadRootIXmlSerializable(xmlReader, rootContract as XmlDataContract, false); } return XmlObjectSerializerReadContext.CreateContext(this, rootContract, dataContractResolver).InternalDeserialize(xmlReader, this.rootType, rootContract, null, null); }
public void WriteObject(System.Xml.XmlDictionaryWriter writer, object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) { }
public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver) { if (typeName == null || typeNamespace == null) { return(null); } return(_context.ResolveNameFromKnownTypes(new XmlQualifiedName(typeName, typeNamespace))); }
public abstract bool TryResolveType(System.Type type, System.Type declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString typeName, out System.Xml.XmlDictionaryString typeNamespace);
internal virtual object InternalReadObject(XmlReaderDelegator reader, bool verifyObjectName, DataContractResolver dataContractResolver) { return(InternalReadObject(reader, verifyObjectName)); }