Base configuration element class.
Наследование: ICloneable
Пример #1
0
        /// <summary>
        /// Creates a new RegionArranger.
        /// </summary>
        /// <param name="regionConfiguration">Region configuration.</param>
        /// <param name="parentConfiguration">Parent configuration.</param>
        public RegionArranger(RegionConfiguration regionConfiguration, ConfigurationElement parentConfiguration)
        {
            if (regionConfiguration == null)
            {
                throw new ArgumentNullException("regionConfiguration");
            }

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

            _regionConfiguration = regionConfiguration;
            _parentConfiguration = parentConfiguration;

            List<string> levelRegions = new List<string>();
            foreach (ConfigurationElement siblingConfiguration in
                _parentConfiguration.Elements)
            {
                RegionConfiguration siblingRegionConfiguration = siblingConfiguration as RegionConfiguration;
                if (siblingRegionConfiguration != null)
                {
                    levelRegions.Add(siblingRegionConfiguration.Name);
                }
            }

            _levelRegions = levelRegions.AsReadOnly();
        }
Пример #2
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;
        }
Пример #3
0
        /// <summary>
        /// Creates a new ElementArranger.
        /// </summary>
        /// <param name="elementConfiguration">Element configuration.</param>
        /// <param name="parentConfiguration">Parent configuration.</param>
        protected internal ElementArranger(
			ElementConfiguration elementConfiguration, ConfigurationElement parentConfiguration)
        {
            if (elementConfiguration == null)
            {
                throw new ArgumentNullException("elementConfiguration");
            }

            _elementConfiguration = elementConfiguration;
            _parentConfiguration = parentConfiguration;
        }
Пример #4
0
        /// <summary>
        /// Creates an element inserter.
        /// </summary>
        /// <param name="elementType">Type of the element.</param>
        /// <param name="sortBy">The sort by.</param>
        /// <param name="groupBy">The group by.</param>
        /// <param name="parentConfiguration">The parent configuration.</param>
        /// <returns>An appropriate inserter.</returns>
        private static IElementInserter CreateElementInserter(
			ElementType elementType,
			SortBy sortBy,
			GroupBy groupBy,
			ConfigurationElement parentConfiguration)
        {
            IElementInserter inserter = null;

            if (sortBy != null)
            {
                inserter = new SortedInserter(elementType, sortBy);
            }

            if (groupBy != null && groupBy.InnerGroupBy != null)
            {
                inserter = new GroupedInserter(groupBy.InnerGroupBy, inserter);
            }

            if (groupBy != null)
            {
                inserter = new GroupedInserter(groupBy, inserter);
            }

            if (inserter == null)
            {
                inserter = new DefaultElementInserter();
            }

            return inserter;
        }
Пример #5
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;
        }
Пример #6
0
        /// <summary>
        /// Recurses through the configuration tree and executes actions against 
        /// each configuration element.
        /// </summary>
        /// <param name="element">Element to process.</param>
        /// <param name="actions">Actions to perform.</param>
        private void TreeProcess(ConfigurationElement element, Action<ConfigurationElement>[] actions)
        {
            if (element != null)
            {
                foreach (ConfigurationElement childElement in element.Elements)
                {
                    foreach (Action<ConfigurationElement> action in actions)
                    {
                        action(childElement);
                    }

                    TreeProcess(childElement, actions);
                }
            }
        }