Пример #1
0
            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));
                }
            }
Пример #2
0
            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));
            }
Пример #3
0
        protected override void Dispose(bool disposing)
        {
            if (_list != _empty)
            {
                _list.ListChanged -= ListChangedHandler;

                if (_disposeList || (_isListCreatedInternally && _disposeCreatedList))
                {
                    _list.Dispose();
                }
            }

            _list = _empty;

            base.Dispose(disposing);
        }
Пример #4
0
        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);
        }
Пример #5
0
 public EditableArrayListTest()
 {
     _testList              = new EditableArrayList(typeof(EditableTestObject));
     _testList.ListChanged += TestList_ListChanged;
 }