Models the current place in an object graph during the construction of an instance. Provides contextual information that can be used to alter the desired construction of child objects
Inheritance: IBuildFrame
        protected override object build(Type pluginType, BuildSession session)
        {
            Current = session.BuildStack.Current;
            Root = session.BuildStack.Root;

            return new ColorRule("Red");
        }
        public void Create_build_stack_and_the_root_is_from_the_ctor()
        {
            var root = new BuildFrame(typeof (IWidget), "Blue", typeof (ColorWidget));
            var stack = new BuildStack();
            stack.Push(root);

            stack.Root.ShouldBeTheSameAs(root);
        }
Esempio n. 3
0
        public bool Contains(BuildFrame frame)
        {
            if (_requestedType == frame._requestedType && _name == frame._name)
            {
                return(true);
            }

            return(_next == null ? false : _next.Contains(frame));
        }
        protected virtual void markBuildStackStart(BuildSession session, Type pluginType)
        {
            if (!doesRecordOnTheStack)
            {
                return;
            }

            var frame = new BuildFrame(pluginType, Name, getConcreteType(pluginType));

            session.BuildStack.Push(frame);
        }
Esempio n. 5
0
 public bool Equals(BuildFrame obj)
 {
     if (ReferenceEquals(null, obj))
     {
         return(false);
     }
     if (ReferenceEquals(this, obj))
     {
         return(true);
     }
     return(Equals(obj._requestedType, _requestedType) && Equals(obj._name, _name) &&
            Equals(obj._concreteType, _concreteType));
 }
        public void true_if_matching()
        {
            var frame1 = new BuildFrame(typeof (IWidget), "red", typeof (ColorWidget));
            var frame2 = new BuildFrame(typeof (IWidget), "red", typeof (ColorWidget));
            var frame3 = new BuildFrame(typeof (IWidget), "green", typeof (ColorWidget));

            frame1.Contains(frame2).ShouldBeTrue();
            frame1.Contains(frame3).ShouldBeFalse();

            frame3.Attach(frame2);

            frame3.Contains(frame1).ShouldBeTrue();
        }
Esempio n. 7
0
        public string ToStackString()
        {
            string     message = "\n1.) " + ToString();
            BuildFrame next    = _next;

            int i = 2;

            while (next != null)
            {
                message += "\n{0}.) {1}".ToFormat(i++, next);
                next     = next._next;
            }

            return(message);
        }
        public void push_a_new_BuildFrame_onto_the_stack()
        {
            var root = new BuildFrame(typeof (IWidget), "Root", typeof (ColorWidget));
            var frame1 = new BuildFrame(typeof (IWidget), "Frame1", typeof (ColorWidget));
            var frame2 = new BuildFrame(typeof (IWidget), "Frame2", typeof (ColorWidget));
            var stack = new BuildStack();
            stack.Push(root);

            stack.Push(frame1);
            stack.Current.ShouldBeTheSameAs(frame1);
            stack.Parent.ShouldBeTheSameAs(root);
            stack.Root.ShouldBeTheSameAs(root);

            stack.Push(frame2);
            stack.Parent.ShouldBeTheSameAs(frame1);
            stack.Current.ShouldBeTheSameAs(frame2);
            stack.Root.ShouldBeTheSameAs(root);

            stack.Pop();
            stack.Parent.ShouldBeTheSameAs(root);
            stack.Current.ShouldBeTheSameAs(frame1);
            stack.Pop();
            stack.Current.ShouldBeTheSameAs(root);
        }
Esempio n. 9
0
 internal void Attach(BuildFrame next)
 {
     _next         = next;
     _next._parent = this;
 }
Esempio n. 10
0
 internal void Attach(BuildFrame next)
 {
     _next = next;
     _next._parent = this;
 }
Esempio n. 11
0
 public bool Equals(BuildFrame obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return Equals(obj._requestedType, _requestedType) && Equals(obj._name, _name) &&
            Equals(obj._concreteType, _concreteType);
 }
Esempio n. 12
0
        public bool Contains(BuildFrame frame)
        {
            if (_requestedType == frame._requestedType && _name == frame._name)
            {
                return true;
            }

            return _next == null ? false : _next.Contains(frame);
        }
Esempio n. 13
0
 public void Attach(BuildFrame next)
 {
     _next         = next;
     _next._parent = this;
 }
Esempio n. 14
0
 public void Attach(BuildFrame next)
 {
     _next = next;
     _next._parent = this;
 }