public IEnumerator GetEnumerator() { _arguments.AddSupportedCapabilities(DataSourceCapabilities.Page); _arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort); _arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount); EditableArrayList list = (EditableArrayList)_objectBinder.List; _arguments.TotalRowCount = list.Count; if (!string.IsNullOrEmpty(_arguments.SortExpression)) { list = new EditableArrayList(list.ItemType, list.Count); list.AddRange(_objectBinder.List); list.SortEx(_arguments.SortExpression); } int start = _arguments.StartRowIndex >= 0? _arguments.StartRowIndex: 0; int count = _arguments.MaximumRows > 0? Math.Min(_arguments.MaximumRows, list.Count): list.Count; for (int i = 0; i < count; i++) { object o = list[i + start]; yield return(o is ICustomTypeDescriptor? o: new ObjectHolder(o, _objectBinder)); } }
public override object GetValue(object component) { object value = base.GetValue(component); if (value == null) { return(value); } if (value is IBindingList && value is ITypedList) { return(value); } return(EditableArrayList.Adapter((IList)value)); }
protected override void Dispose(bool disposing) { if (_list != _empty) { _list.ListChanged -= ListChangedHandler; if (_disposeList || (_isListCreatedInternally && _disposeCreatedList)) { _list.Dispose(); } } _list = _empty; base.Dispose(disposing); }
private void TestList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { EditableArrayList array = sender as EditableArrayList; Assert.IsNotNull(array); if (e.Action != NotifyCollectionChangedAction.Reset) { Assert.That(array.IsDirty); } EditableTestObject o = (EditableTestObject)(e.NewItems != null? e.NewItems[0]: e.OldItems != null ? e.OldItems[0]: null); Console.WriteLine("CollectionChanged (ID:{3}). Type: {0}, OldIndex: {1}, NewIndex: {2}", e.Action, e.OldStartingIndex, e.NewStartingIndex, o != null? o.ID: -1); }
public EditableArrayListTest() { _testList = new EditableArrayList(typeof(EditableTestObject)); _testList.ListChanged += TestList_ListChanged; }