private object GetFieldValue(AutoGeneratedFieldProperties property, object obj, RecordField field, System.Data.DataRow dataRow)
{
if (field != null && field.ServerMapping.IsNotEmpty())
{
string[] mapping = field.ServerMapping.Split('.');
if (mapping.Length > 1)
{
for (int i = 0; i < mapping.Length; i++)
{
if (dataRow != null && dataRow.IsNull(mapping[i]))
{
return null;
}
PropertyInfo p = obj.GetType().GetProperty(mapping[i]);
try
{
obj = p.GetValue(obj, null);
}
catch (NullReferenceException e)
{
throw new NullReferenceException(String.Format("Mapped property '{0}' doesn't exist", mapping[i]));
}
if (obj == null)
{
return null;
}
}
return obj;
}
}
return (dataRow != null && dataRow.IsNull(property.DataField)) ? null : DataBinder.GetPropertyValue(obj, property.DataField);
}