AddArranger() public method

Adds an arranger to the responsibility chain.
public AddArranger ( IElementArranger arranger ) : void
arranger IElementArranger Child arranger to add.
return void
コード例 #1
0
        public void CanArrangeTest()
        {
            ChainElementArranger chain = new ChainElementArranger();
            FieldElement fieldElement = new FieldElement();

            //
            // No arrangers in chain
            //
            Assert.IsFalse(
                chain.CanArrange(fieldElement),
                "Empty chain element arranger should not be able to arrange an element.");

            //
            // Add an arranger that can't arrange the element
            //
            TestElementArranger disabledArranger = new TestElementArranger(false);
            chain.AddArranger(disabledArranger);
            Assert.IsFalse(chain.CanArrange(fieldElement), "Unexpected return value from CanArrange.");

            //
            // Add an arranger that can arrange the element
            //
            TestElementArranger enabledArranger = new TestElementArranger(true);
            chain.AddArranger(enabledArranger);
            Assert.IsTrue(chain.CanArrange(fieldElement), "Unexpected return value from CanArrange.");

            //
            // Null
            //
            Assert.IsFalse(chain.CanArrange(null), "Unexpected return value from CanArrange.");
        }
コード例 #2
0
        public void UnsupportedArrangeNoParentTest()
        {
            ChainElementArranger chain = new ChainElementArranger();
            FieldElement fieldElement = new FieldElement();

            //
            // Add an arranger that can't arrange the element
            //
            TestElementArranger disabledArranger = new TestElementArranger(false);
            chain.AddArranger(disabledArranger);
            Assert.IsFalse(chain.CanArrange(fieldElement), "Unexpected return value from CanArrange.");

            chain.ArrangeElement(null, fieldElement);
        }
コード例 #3
0
        /// <summary>
        /// Creates an arranger for the children of elements associated with the
        /// specified cofiguration.
        /// </summary>
        /// <param name="parentConfiguration">Parent configuration.</param>
        /// <returns>Element arranger for children.</returns>
        internal static IElementArranger CreateChildrenArranger(ConfigurationElement parentConfiguration)
        {
            ChainElementArranger childrenArranger = new ChainElementArranger();

            foreach (ConfigurationElement childConfiguration in parentConfiguration.Elements)
            {
                IElementArranger childElementArranger = CreateElementArranger(
                    childConfiguration, parentConfiguration);

                if (childElementArranger != null)
                {
                    childrenArranger.AddArranger(childElementArranger);
                }
            }

            return(childrenArranger);
        }
コード例 #4
0
        /// <summary>
        /// Creates an arranger for the children of elements associated with the 
        /// specified cofiguration.
        /// </summary>
        /// <param name="parentConfiguration">Parent configuration.</param>
        /// <returns>Element arranger for children.</returns>
        internal static IElementArranger CreateChildrenArranger(ConfigurationElement parentConfiguration)
        {
            ChainElementArranger childrenArranger = new ChainElementArranger();
            foreach (ConfigurationElement childConfiguration in parentConfiguration.Elements)
            {
                IElementArranger childElementArranger = CreateElementArranger(
                    childConfiguration, parentConfiguration);

                if (childElementArranger != null)
                {
                    childrenArranger.AddArranger(childElementArranger);
                }
            }

            return childrenArranger;
        }
コード例 #5
0
        public void UnsupportedArrangeWithParentTest()
        {
            GroupElement parentElement = new GroupElement();
            ChainElementArranger chain = new ChainElementArranger();
            FieldElement fieldElement = new FieldElement();

            //
            // Add an arranger that can't arrange the element
            //
            TestElementArranger disabledArranger = new TestElementArranger(false);
            chain.AddArranger(disabledArranger);
            Assert.IsFalse(chain.CanArrange(fieldElement), "Unexpected return value from CanArrange.");

            chain.ArrangeElement(parentElement, fieldElement);
            Assert.IsTrue(parentElement.Children.Contains(fieldElement));
        }
コード例 #6
0
 public void AddArrangerNullTest()
 {
     ChainElementArranger chainArranger = new ChainElementArranger();
     chainArranger.AddArranger(null);
 }