protected virtual bool CanConvert(
PropertyInfo sourceProperty,
PropertyInfo targetProperty,
out PropertyInfo finalProperty)
{
Guard.CheckArgumentNotNull(sourceProperty, "sourceProperty");
Guard.CheckArgumentNotNull(targetProperty, "targetProperty");
finalProperty = null;
bool result = false;
ValueConverter typeChecker = CreateValueConverter();
if (sourceProperty.Name.Equals(targetProperty.Name))
{
result = typeChecker.CanConvert(sourceProperty.PropertyType, targetProperty.PropertyType);
}
else if (targetProperty.Name.StartsWith(sourceProperty.Name, StringComparison.Ordinal))
{
string remainder = targetProperty.Name.Substring(sourceProperty.Name.Length);
finalProperty = sourceProperty.PropertyType.GetProperty(remainder);
if (finalProperty != null)
{
result = typeChecker.CanConvert(finalProperty.PropertyType, targetProperty.PropertyType);
}
}
return(result);
}