/// <summary> /// Determines whether a <see cref="DateCollectionItem"/> is in the collection. /// </summary> /// <param name="item">The <see cref="DateCollectionItem"/> to locate in the collection. The element to locate can be a null reference.</param> /// <returns>true if value is found in the collection; otherwise, false.</returns> public bool Contains(DateCollectionItem item) { if (item == null) { return(false); } return(_dateCollection.Contains(item)); }
/// <summary> /// Determines the index of a specific <see cref="DateCollectionItem"/> in the current instance. /// </summary> /// <param name="item">The <see cref="DateCollectionItem"/> to locate in the current instance.</param> /// <returns>The index of value if found in the current instance; otherwise, -1.</returns> public int IndexOf(DateCollectionItem item) { if (item == null) { throw new ArgumentNullException("item"); } return(_dateCollection.IndexOf(item)); }
/// <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> /// Inserts a <see cref="DateCollectionItem"/> to the collection at the specified position. /// </summary> /// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="item">The <see cref="DateCollectionItem"/> to insert into the Collection.</param> public void Insert(int index, DateCollectionItem item) { if (item == null) { throw new ArgumentNullException("item"); } _dateCollection.Insert(index, item); if (_isTrackingViewState) { ((IStateManager)item).TrackViewState(); _saveAll = true; } }
/// <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); }
/// <summary> /// Removes a <see cref="DateCollectionItem"/> from the collection. /// </summary> /// <param name="item">The <see cref="DateCollectionItem"/> to remove from the collection.</param> public void Remove(DateCollectionItem item) { if (item == null) { throw new ArgumentNullException("item"); } int index = IndexOf(item); if (index >= 0) { RemoveAt(index); } if (_isTrackingViewState) { _saveAll = true; } }
void IStateManager.LoadViewState(object savedState) { if (savedState == null) { return; } if (savedState is Pair) { Pair p = (Pair)savedState; ArrayList indices = (ArrayList)p.First; ArrayList states = (ArrayList)p.Second; for (int i = 0; i < indices.Count; i++) { int index = (int)indices[i]; if (index < this.Count) { ((IStateManager)_dateCollection[index]).LoadViewState(states[i]); } else { DateCollectionItem dateItem = new DateCollectionItem(); Add(dateItem); ((IStateManager)dateItem).LoadViewState(states[i]); } } } else if (savedState is ArrayList) { _saveAll = true; ArrayList states = (ArrayList)savedState; _dateCollection = new ArrayList(states.Count); for (int i = 0; i < states.Count; i++) { DateCollectionItem dateItem = new DateCollectionItem(); Add(dateItem); ((IStateManager)dateItem).LoadViewState(states[i]); } } }
/// <summary> /// Indicates if a Date is already in the collection. /// </summary> /// <param name="dateItem"><see cref="DateCollectionItem"/> that contains the date to check.</param> /// <returns>True if the date is already present, otherwise false.</returns> public bool IsDatePresent(DateCollectionItem dateItem) { return(IsDatePresent(dateItem.Date)); }
/// <summary> /// Adds a <see cref="LabelValueCollectionItem"/> to the collection /// </summary> /// <param name="item">The <see cref="LabelValueCollectionItem"/> to add to the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(DateCollectionItem item) { return(_labelValueCollection.Add(item)); }
/// <summary> /// Inserts a <see cref="LabelValueCollectionItem"/> to the collection at the specified position. /// </summary> /// <param name="index">The zero-based index at which value should be inserted.</param> /// <param name="item">The <see cref="LabelValueCollectionItem"/> to insert into the Collection.</param> public void Insert(int index, DateCollectionItem item) { _labelValueCollection[index] = item; }