public object Read(XmlNode node) { NetReflector.CheckNull(node, "node", typeof(XmlNode)); IXmlSerialiser serialiser = table[node.Name]; if (serialiser == null) { throw new NetReflectorException(string.Format("No loaded type is marked up with a ReflectorType attribute that matches the Xml node ({0}). Xml Source: {1}", node.Name, node.OuterXml)); } return(serialiser.Read(node, table)); }
// refactor with method above??? protected object ReadValue(XmlNode node, NetReflectorTypeTable table) { IXmlSerialiser serialiser = table[node.Name]; if (serialiser == null) { return(node.InnerText); } else { // fix return(serialiser.Read(node, table)); } }
protected virtual object Read(XmlNode childNode, Type instanceType, NetReflectorTypeTable table) { if (ReflectionUtil.IsCommonType(instanceType)) { if ((childNode.Attributes != null) && (childNode.Attributes.Count > 0)) { throw new NetReflectorException( string.Format("Attributes are not allowed on {3} types - {0} attributes(s) found on '{1}'" + Environment.NewLine + "Xml: {2}", childNode.Attributes.Count, childNode.Name, childNode.OuterXml, instanceType.Name)); } return(childNode.InnerText); } else { ReflectorTypeAttribute reflectorTypeAttribute = ReflectorTypeAttribute.GetAttribute(instanceType); if (reflectorTypeAttribute == null) { if (!string.IsNullOrEmpty(attribute.InstanceTypeKey)) { throw new NetReflectorException( string.Format("Unable to find reflector type for '{0}' when deserialising '{1}' - '{3}' has not been set" + Environment.NewLine + "Xml: {2}", instanceType.Name, childNode.Name, childNode.OuterXml, attribute.InstanceTypeKey)); } else { throw new NetReflectorException( string.Format("Unable to find reflector type for '{0}' when deserialising '{1}'" + Environment.NewLine + "Xml: {2}", instanceType.Name, childNode.Name, childNode.OuterXml)); } } IXmlSerialiser serialiser = table[reflectorTypeAttribute.Name]; // null check return(serialiser.Read(childNode, table)); } }