System.Windows.Forms.ListBindingHelper.GetListName C# (CSharp) Method

GetListName() public static method

public static GetListName ( object list, Array listAccessors ) : string
list object
listAccessors Array
return string
        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;
        }

Usage Example

Example #1
0
 public virtual string GetListName(PropertyDescriptor[] listAccessors)
 {
     return(ListBindingHelper.GetListName(list, listAccessors));
 }