/// <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);
}
}
}