protected virtual object ReadClassInstance (XmlTypeMapping typeMap, bool isNullable, bool checkType)
{
if (isNullable && ReadNull()) return null;
if (checkType)
{
System.Xml.XmlQualifiedName t = GetXsiType();
if (t != null)
{
XmlTypeMapping realMap = typeMap.GetRealElementMap (t.Name, t.Namespace);
if (realMap == null) {
if (typeMap.TypeData.Type == typeof(object))
return ReadTypedPrimitive (t);
else
throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)t);
}
if (realMap != typeMap)
return ReadObject (realMap, false, false);
}
else if (typeMap.TypeData.Type == typeof(object))
return ReadTypedPrimitive (AnyType);
}
object ob = Activator.CreateInstance (typeMap.TypeData.Type, true);
Reader.MoveToElement();
bool isEmpty = Reader.IsEmptyElement;
ReadClassInstanceMembers (typeMap, ob);
if (isEmpty) Reader.Skip();
else ReadEndElement();
return ob;
}