System.Windows.Automation.CacheRequest.Push C# (CSharp) Method

Push() public method

public Push ( ) : void
return void
        public void Push()
        {
            if (_cacheStack == null)
            {
                _cacheStack = new Stack();
            }
            _cacheStack.Push(this);
            lock (this._lock)
            {
                this._cRef++;
            }
        }

Usage Example

Beispiel #1
0
        public void PushPopTest()
        {
            CacheRequest defaultCR = CacheRequest.Current;
            CacheRequest target = new CacheRequest();
            target.TreeScope = TreeScope.Children;
            target.Push();
            CacheRequest target2 = new CacheRequest();
            target2.TreeScope = TreeScope.Subtree;
            target2.Push();

            // Try to change target2 - this should fail
            try
            {
                target2.TreeScope = TreeScope.Descendants;

                Assert.Fail("exception expected");
            }
            catch (System.InvalidOperationException)
            {
            }

            target2.Pop();
            target.Pop();
            Assert.AreEqual(CacheRequest.Current, defaultCR);
        }
All Usage Examples Of System.Windows.Automation.CacheRequest::Push