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

GetListNameFromType() private static method

private static GetListNameFromType ( Type type ) : string
type Type
return string
        private static string GetListNameFromType(Type type) {
            string name;

            if (typeof(Array).IsAssignableFrom(type)) {
                // If the type is Customers[], this will return "Customers"
                name = type.GetElementType().Name;
            }
            else if (typeof(IList).IsAssignableFrom(type)) {
                // If the type is BindingList<T>, TCollection, TList (or equiv), this will return "T"
                PropertyInfo indexer = GetTypedIndexer(type);
                if (indexer != null)
                {
                    name = indexer.PropertyType.Name;
                }
                else
                {
                    name = type.Name;
                }
            }
            else {
                // Fallback to type name
                name = type.Name;
            }

            return name;
        }