public static string GetListName(object list, PropertyDescriptor[] listAccessors) {
string name;
if (list == null) {
return string.Empty;
}
ITypedList typedList = list as ITypedList;
if (typedList != null) {
// Use typed list
name = typedList.GetListName(listAccessors);
}
else {
Type type;
// We always resolve via type in this case (not an instance)
if ((null == listAccessors) || (listAccessors.Length == 0)) {
Type listAsType = list as Type;
if (listAsType != null) {
type = listAsType;
}
else {
type = list.GetType();
}
}
else {
// We don't walk down - always use type name
PropertyDescriptor pd = listAccessors[0];
type = pd.PropertyType;
}
name = GetListNameFromType(type);
}
return name;
}