private void SetFlag(CollectionViewFlags flags, bool value) { if (value) { _flags = _flags | flags; } else { _flags = _flags & ~flags; } }
public PagedCollectionView(IEnumerable source, bool isDataSorted, bool isDataInGroupOrder) { NotifyCollectionChangedEventHandler handler = null; this._cachedPageIndex = -1; this._currentChangedMonitor = new SimpleMonitor(); this._flags = CollectionViewFlags.ShouldProcessCollectionChanged; this._pageIndex = -1; if (source == null) { throw new ArgumentNullException("source"); } this._sourceCollection = source; this.SetFlag(CollectionViewFlags.IsDataSorted, isDataSorted); this.SetFlag(CollectionViewFlags.IsDataInGroupOrder, isDataInGroupOrder); this._temporaryGroup = new CollectionViewGroupRoot(this, isDataInGroupOrder); this._group = new CollectionViewGroupRoot(this, false); this._group.GroupDescriptionChanged += new EventHandler(this.OnGroupDescriptionChanged); this._group.GroupDescriptions.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnGroupByChanged); this.CopySourceToInternalList(); this._trackingEnumerator = source.GetEnumerator(); if (this._internalList.Count > 0) { this.SetCurrent(this._internalList[0], 0, 1); } else { this.SetCurrent(null, -1, 0); } this.SetFlag(CollectionViewFlags.CachedIsEmpty, this.Count == 0); this._pollForChanges = !(source is INotifyCollectionChanged); if (!this._pollForChanges) { if (handler == null) { handler = delegate (object sender, NotifyCollectionChangedEventArgs args) { this.ProcessCollectionChanged(args); }; } (source as INotifyCollectionChanged).CollectionChanged += handler; } }
/// <summary> /// Sets the specified Flag(s) /// </summary> /// <param name="flags">Flags we want to set</param> /// <param name="value">Value we want to set these flags to</param> private void SetFlag(CollectionViewFlags flags, bool value) { if (value) { this._flags = this._flags | flags; } else { this._flags = this._flags & ~flags; } }
/// <summary> /// Returns true if specified flag in flags is set. /// </summary> /// <param name="flags">Flag we are checking for</param> /// <returns>Whether the specified flag is set</returns> private bool CheckFlag(CollectionViewFlags flags) { return (this._flags & flags) != 0; }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // returns true if ANY flag in flags is set. private bool CheckFlag(CollectionViewFlags flags) { return((_flags & flags) != 0); }