private Type GetPropertyItemType (Type objType, string propName)
{
Type propType = GetPropertyType(objType, propName);
if (propType == null)
return null;
Type enumType = GetGenericInterface(propType, typeof(IEnumerable<>));
Type itemType = null;
if (enumType != null)
itemType = enumType.GetGenericArguments()[0]; // T
else {
var dicType = GetGenericInterface(propType, typeof(IDictionary<,>));
if (dicType != null)
itemType = dicType.GetGenericArguments()[1]; // TValue
}
if (itemType != null) {
if (DefaultItemTypes.ContainsKey(itemType))
itemType = DefaultItemTypes[itemType];
return itemType;
}
if (IsTypeDictionary(propType))
return null;
return propType;
}