Example #1
0
        public void Clear()
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "PrincipalCollection", "Clear");

            CheckDisposed();

            // Ask the StoreCtx to verify that this group can be cleared.  Right now, the only
            // reason it couldn't is if it's an AD group with one principals that are members of it
            // by virtue of their primaryGroupId.
            //
            // If storeCtxToUse == null, then we must be unpersisted, in which case there clearly
            // can't be any such primary group members pointing to this group on the store.
            StoreCtx storeCtxToUse = _owningGroup.GetStoreCtxToUse();
            string   explanation;

            Debug.Assert(storeCtxToUse != null || _owningGroup.unpersisted == true);

            if ((storeCtxToUse != null) && (!storeCtxToUse.CanGroupBeCleared(_owningGroup, out explanation)))
            {
                throw new InvalidOperationException(explanation);
            }

            MarkChange();

            // We wipe out everything that's been inserted/removed
            _insertedValuesPending.Clear();
            _removedValuesPending.Clear();
            _insertedValuesCompleted.Clear();
            _removedValuesCompleted.Clear();

            // flag that the collection has been cleared, so the StoreCtx and PrincipalCollectionEnumerator
            // can take appropriate action
            _clearPending = true;
        }
        public void Clear()
        {
            string str = null;

            this.CheckDisposed();
            StoreCtx storeCtxToUse = this.owningGroup.GetStoreCtxToUse();

            if (storeCtxToUse == null || storeCtxToUse.CanGroupBeCleared(this.owningGroup, out str))
            {
                this.MarkChange();
                this.insertedValuesPending.Clear();
                this.removedValuesPending.Clear();
                this.insertedValuesCompleted.Clear();
                this.removedValuesCompleted.Clear();
                this.clearPending = true;
                return;
            }
            else
            {
                throw new InvalidOperationException(str);
            }
        }