Standard IElementArranger implementation.
Inheritance: IElementArranger
Beispiel #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);
        }
        /// <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;
        }