/// <summary>
/// Reads the value from the XML node.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="propertyName">Name of the property.</param>
/// <exception cref="ArgumentNullException">The <paramref name="reader"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentException">The <paramref name="propertyName"/> is <c>null</c> or whitespace.</exception>
/// <remarks>This method does not check whether the property exists. This is the responsibility of the caller.</remarks>
private void ReadValueFromXmlNode(XmlReader reader, string propertyName)
{
Argument.IsNotNull("reader", reader);
Argument.IsNotNullOrWhitespace("propertyName", propertyName);
var propertyData = PropertyDataManager.GetPropertyData(GetType(), propertyName);
object value = null;
switch (reader.NodeType)
{
case XmlNodeType.Attribute:
value = GetObjectFromXmlAttribute(reader, propertyData);
break;
case XmlNodeType.Element:
value = GetObjectFromXmlElement(reader, propertyName);
break;
default:
string error = string.Format("Xml node type '{0}' with local name '{1}' is not supported", reader.NodeType, ObjectToStringHelper.ToString(reader.LocalName));
Log.Error(error);
throw new NotSupportedException(error);
}
if (value != null)
{
SetValue(propertyData, value, false, false);
}
}