Element arranger for adding members in regions.
Inheritance: IElementArranger
Ejemplo n.º 1
0
        /// <summary>
        /// Creates an element arranger using the specified configuration information.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="parentConfiguration">The parent configuration.</param>
        /// <returns>
        /// Returns an IElementArranger if succesful, otherwise null.
        /// </returns>
        public static IElementArranger CreateElementArranger(
            ConfigurationElement configuration,
            ConfigurationElement parentConfiguration)
        {
            IElementArranger arranger = null;

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            //
            // If this is an element reference, build the arranger using the referenced
            // element configuration instead.
            //
            ElementReferenceConfiguration elementReference = configuration as ElementReferenceConfiguration;

            if (elementReference != null && elementReference.ReferencedElement != null)
            {
                configuration = elementReference.ReferencedElement;
            }

            ElementConfiguration elementConfiguration = configuration as ElementConfiguration;

            if (elementConfiguration != null)
            {
                arranger = new ElementArranger(elementConfiguration, parentConfiguration);
            }
            else
            {
                RegionConfiguration regionConfiguration = configuration as RegionConfiguration;
                if (regionConfiguration != null)
                {
                    arranger = new RegionArranger(regionConfiguration, parentConfiguration);
                }
                else
                {
                    arranger = CreateChildrenArranger(configuration);
                }
            }

            return(arranger);
        }
Ejemplo n.º 2
0
        public void CanArrangeTest()
        {
            RegionConfiguration methodRegionConfiguration = new RegionConfiguration();
            methodRegionConfiguration.Name = "Methods";
            ElementConfiguration methodConfiguration = new ElementConfiguration();
            methodConfiguration.ElementType = ElementType.Method;
            methodRegionConfiguration.Elements.Add(methodConfiguration);

            RegionConfiguration propertyRegionConfiguration = new RegionConfiguration();
            propertyRegionConfiguration.Name = "Properties";
            ElementConfiguration propertyConfiguration = new ElementConfiguration();
            propertyConfiguration.ElementType = ElementType.Property;
            propertyRegionConfiguration.Elements.Add(propertyConfiguration);

            ElementConfiguration parentConfiguration = new ElementConfiguration();
            parentConfiguration.ElementType = ElementType.Type;

            RegionArranger methodRegionArranger = new RegionArranger(
                methodRegionConfiguration, parentConfiguration);

            RegionArranger propertyRegionArranger = new RegionArranger(
                propertyRegionConfiguration, parentConfiguration);

            MethodElement method = new MethodElement();
            method.Name = "DoSomething";

            Assert.IsTrue(
                methodRegionArranger.CanArrange(method),
                "Expected region arranger to be able to arrange the element.");

            Assert.IsFalse(
                propertyRegionArranger.CanArrange(method),
                "Expected region arranger to not be able to arrange the element.");

            Assert.IsFalse(
                methodRegionArranger.CanArrange(null),
                "Expected region arranger to not be able to arrange a null element.");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an element arranger using the specified configuration information.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="parentConfiguration">The parent configuration.</param>
        /// <returns>
        /// Returns an IElementArranger if succesful, otherwise null.
        /// </returns>
        public static IElementArranger CreateElementArranger(
			ConfigurationElement configuration,
			ConfigurationElement parentConfiguration)
        {
            IElementArranger arranger = null;

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            //
            // If this is an element reference, build the arranger using the referenced
            // element configuration instead.
            //
            ElementReferenceConfiguration elementReference = configuration as ElementReferenceConfiguration;
            if (elementReference != null && elementReference.ReferencedElement != null)
            {
                configuration = elementReference.ReferencedElement;
            }

            ElementConfiguration elementConfiguration = configuration as ElementConfiguration;
            if (elementConfiguration != null)
            {
                arranger = new ElementArranger(elementConfiguration, parentConfiguration);
            }
            else
            {
                RegionConfiguration regionConfiguration = configuration as RegionConfiguration;
                if (regionConfiguration != null)
                {
                    arranger = new RegionArranger(regionConfiguration, parentConfiguration);
                }
                else
                {
                    arranger = CreateChildrenArranger(configuration);
                }
            }

            return arranger;
        }
Ejemplo n.º 4
0
 public void CreateNullRegionConfigurationTest()
 {
     RegionArranger regionArranger = new RegionArranger(null, new ElementConfiguration());
 }
Ejemplo n.º 5
0
 public void CreateNullParentConfigurationTest()
 {
     RegionArranger regionArranger = new RegionArranger(new RegionConfiguration(), null);
 }