private object InstantiateObject(Type type, IClassMap classMap, XmlNode xmlObject) { IObjectManager om = this.Context.ObjectManager; string element = classMap.GetDocElement(); string identity = ""; string separator = classMap.GetIdentitySeparator(); foreach (IPropertyMap idPropertyMap in classMap.GetIdentityPropertyMaps()) { if (identity.Length > 0) identity += separator; if (idPropertyMap.DocElement.Length > 0) { XmlNode idNode = xmlObject.SelectSingleNode(idPropertyMap.GetDocElement()); if (idNode != null) identity += idNode.InnerText; else throw new NPersistException(String.Format("Could not find id element {0} for property {1} of class {2} in element {3}", idPropertyMap.GetDocElement(), idPropertyMap.Name, type.ToString(), xmlObject.Name)); } else { string attribName = idPropertyMap.GetDocAttribute(); if (xmlObject.Attributes[attribName] != null) identity += xmlObject.Attributes[attribName].Value; else throw new NPersistException(String.Format("Could not find id attribute {0} for property {1} of class {2} in element {3}", attribName, idPropertyMap.Name, type.ToString(), xmlObject.Name)); } } return this.Context.GetObjectById(identity, type, true); }