MSDN documentation makes it very clear:
Parameters
name
Type: System.String
The string containing the name of the public property to get.
No class can contain property with dot (.) in name.
What you are trying to achieve (I think) is to check child property (e.g. your class has property named abc
and class of that property has its own property named key
).
To do so, you have to use recursion.
public bool HasPropertyInPath(
Type checkedType,
string propertyPath,
Type propertyType)
{
int dotIndex = propertyPath.IndexOf('.');
if (dotIndex != -1)
{
PropertyInfo topPropertyInfo
= checkedType.GetProperty(propertyPath.Substring(0, dotIndex));
if (topPropertyInfo == null)
{
return false;
}
return HasPropertyInPath(
topPropertyInfo.PropertyType,
propertyPath.Substring(dotIndex + 1),
propertyType);
}
PropertyInfo propertyInfo = checkedType.GetProperty(propertyPath);
return (propertyInfo != null && propertyInfo.PropertyType == propertyType);
}
Then you can use it like this:
if (HasPropertyInPath(typeof(T), filterDescriptor.Member, typeof(string))
{
isMemberStringType = true;
filterDescriptor.Value = filterDescriptor.Value ?? string.Empty;
}
Above code is not tested but should check children properties.