InvokeReader() private method

private InvokeReader ( XmlMapping mapping, XmlReader xmlReader, XmlDeserializationEvents events, string encodingStyle ) : object
mapping XmlMapping
xmlReader XmlReader
events XmlDeserializationEvents
encodingStyle string
return object
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.Deserialize5"]/*' />
        public object Deserialize(XmlReader xmlReader, string encodingStyle, XmlDeserializationEvents events)
        {
            events.sender = this;
            try {
                if (primitiveType != null)
                {
                    if (encodingStyle != null && encodingStyle.Length > 0)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.XmlInvalidEncodingNotEncoded1, encodingStyle));
                    }
                    return(DeserializePrimitive(xmlReader, events));
                }
                else if (tempAssembly == null || typedSerializer)
                {
                    XmlSerializationReader reader = CreateReader();
                    reader.Init(xmlReader, events, encodingStyle, tempAssembly);
                    try {
                        return(Deserialize(reader));
                    }
                    finally {
                        reader.Dispose();
                    }
                }
                else
                {
                    return(tempAssembly.InvokeReader(mapping, xmlReader, events, encodingStyle));
                }
            }
            catch (Exception e) {
                if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException)
                {
                    throw;
                }
                if (e is TargetInvocationException)
                {
                    e = e.InnerException;
                }

                if (xmlReader is IXmlLineInfo)
                {
                    IXmlLineInfo lineInfo = (IXmlLineInfo)xmlReader;
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeErrorDetails, lineInfo.LineNumber.ToString(CultureInfo.InvariantCulture), lineInfo.LinePosition.ToString(CultureInfo.InvariantCulture)), e);
                }
                else
                {
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeError), e);
                }
            }
            catch {
                if (xmlReader is IXmlLineInfo)
                {
                    IXmlLineInfo lineInfo = (IXmlLineInfo)xmlReader;
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeErrorDetails, lineInfo.LineNumber.ToString(CultureInfo.InvariantCulture), lineInfo.LinePosition.ToString(CultureInfo.InvariantCulture)), null);
                }
                else
                {
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeError), (Exception)null);
                }
            }
        }
示例#2
0
        /// <include file='doc\XmlSerializer.uex' path='docs/doc[@for="XmlSerializer.Deserialize2"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public object Deserialize(XmlReader xmlReader)
        {
            try {
                if (tempAssembly == null)
                {
                    XmlSerializationReader reader = CreateReader();
                    reader.Init(xmlReader, events);
                    return(Deserialize(reader));
                }
                return(tempAssembly.InvokeReader(methodIndex, xmlReader, events));
            }
            catch (Exception e) {
                if (e is TargetInvocationException)
                {
                    e = e.InnerException;
                }

                if (xmlReader is XmlTextReader)
                {
                    XmlTextReader xmlTextReader = (XmlTextReader)xmlReader;
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeErrorDetails, xmlTextReader.LineNumber.ToString(), xmlTextReader.LinePosition.ToString()), e);
                }
                else
                {
                    throw new InvalidOperationException(Res.GetString(Res.XmlSerializeError), e);
                }
            }
        }