void ResetList() { if (!is_initialized) { return; } IList l; object source = ListBindingHelper.GetList(datasource, datamember); // // If original source is null, then create a new object list // Otherwise, try to infer the list item type // if (datasource == null) { l = new BindingList <object>(); //list_defaulted = true; } else if (source == null) { //Infer type based on datasource and datamember, // where datasource is an empty IEnumerable // and need to find out the datamember type Type property_type = ListBindingHelper.GetListItemProperties(datasource) [datamember].PropertyType; Type t = typeof(BindingList <>).MakeGenericType(new Type [] { property_type }); l = (IList)Activator.CreateInstance(t); } else if (source is IList) { l = (IList)source; } else if (source is IEnumerable) { IList new_list = GetListFromEnumerable((IEnumerable)source); l = new_list == null ? list : new_list; } else if (source is Type) { Type t = typeof(BindingList <>).MakeGenericType(new Type [] { (Type)source }); l = (IList)Activator.CreateInstance(t); } else { Type t = typeof(BindingList <>).MakeGenericType(new Type[] { source.GetType() }); l = (IList)Activator.CreateInstance(t); l.Add(source); } SetList(l); }
void SetList(IList l) { if (list is IBindingList) { ((IBindingList)list).ListChanged -= IBindingListChangedHandler; } list = l; item_type = ListBindingHelper.GetListItemType(list); item_has_default_ctor = item_type.GetConstructor(Type.EmptyTypes) != null; list_is_ibinding = list is IBindingList; if (list_is_ibinding) { ((IBindingList)list).ListChanged += IBindingListChangedHandler; if (list is IBindingListView) { ((IBindingListView)list).Filter = filter; } } ResetBindings(true); }
public override PropertyDescriptorCollection GetItemProperties() { return(ListBindingHelper.GetListItemProperties(list)); }
public virtual string GetListName(PropertyDescriptor[] listAccessors) { return(ListBindingHelper.GetListName(list, listAccessors)); }
public virtual PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors) { return(ListBindingHelper.GetListItemProperties(list, listAccessors)); }