/// <summary> /// Adds a <see cref="DateCollectionItem"/> to the collection /// </summary> /// <param name="item">The <see cref="DateCollectionItem"/> to add to the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(DateCollectionItem item) { if (item == null) { throw new ArgumentNullException("item"); } if (_isTrackingViewState) { ((IStateManager)item).TrackViewState(); item.SetDirty(); } return(_dateCollection.Add(item)); }
/// <summary> /// When implemented by a class, saves the changes to a server control's view state to an /// <see cref="T:System.Object"/> . /// </summary> /// <returns> /// The <see langword="Object"/> that contains the view state changes. /// </returns> public object SaveViewState() { if (_saveAll == true) { // Save all items. ArrayList states = new ArrayList(Count); for (int i = 0; i < Count; i++) { DateCollectionItem dateItem = (DateCollectionItem)_dateCollection[i]; dateItem.SetDirty(); states.Add(((IStateManager)dateItem).SaveViewState()); } if (states.Count > 0) { return(states); } else { return(null); } } else { // Save only the dirty items. ArrayList indices = new ArrayList(); ArrayList states = new ArrayList(); for (int i = 0; i < Count; i++) { DateCollectionItem dateItem = (DateCollectionItem)_dateCollection[i]; object state = ((IStateManager)dateItem).SaveViewState(); if (state != null) { states.Add(state); indices.Add(i); } } if (indices.Count > 0) { return(new Pair(indices, states)); } } return(null); }