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

Push() public méthode

Pushes the given object onto the stack.
public Push ( object context ) : void
context object
Résultat void
        public void Push(object context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (_contextStack == null)
            {
                _contextStack = new ArrayList();
            }
            _contextStack.Add(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::Push