System.ComponentModel.Design.Serialization.ContextStack.Pop C# (CSharp) Méthode

Pop() public méthode

Pops the current object off of the stack, returning its value.
public Pop ( ) : object
Résultat object
        public object Pop()
        {
            object context = null;

            if (_contextStack != null && _contextStack.Count > 0)
            {
                int idx = _contextStack.Count - 1;
                context = _contextStack[idx];
                _contextStack.RemoveAt(idx);
            }

            return context;
        }

Usage Example

        public void IntegrityTest()
        {
            ContextStack stack = new ContextStack();

            string one = "one";
            string two = "two";
            stack.Push(two);
            stack.Push(one);
            Assert.Same(one, stack[typeof(string)]);
            Assert.Same(one, stack[0]);
            Assert.Same(one, stack.Current);

            Assert.Same(one, stack.Pop());

            Assert.Same(two, stack[typeof(string)]);
            Assert.Same(two, stack[0]);
            Assert.Same(two, stack.Current);

            string three = "three";
            stack.Append(three);

            Assert.Same(two, stack[typeof(string)]);
            Assert.Same(two, stack[0]);
            Assert.Same(two, stack.Current);

            Assert.Same(two, stack.Pop());

            Assert.Same(three, stack[typeof(string)]);
            Assert.Same(three, stack[0]);
            Assert.Same(three, stack.Current);
            Assert.Same(three, stack.Pop());

            Assert.Null(stack.Pop());
            Assert.Null(stack.Current);
        }
All Usage Examples Of System.ComponentModel.Design.Serialization.ContextStack::Pop