/// <summary> /// Intitializes the arranger for children of the region. /// </summary> private void InitializeChildrenArranger() { if (_childrenArranger == null) { _childrenArranger = ElementArrangerFactory.CreateChildrenArranger(_regionConfiguration); } }
/// <summary> /// Adds an arranger to the responsibility chain. /// </summary> /// <param name="arranger">Child arranger to add.</param> public void AddArranger(IElementArranger arranger) { if (arranger == null) { throw new ArgumentNullException("arranger"); } _arrangers.Add(arranger); }
/// <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); }
/// <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> /// Arranges the element in within the code tree represented in the specified /// builder. /// </summary> /// <param name="parentElement">The parent element.</param> /// <param name="codeElement">The code element.</param> public virtual void ArrangeElement(ICodeElement parentElement, ICodeElement codeElement) { if (codeElement.Children.Count > 0) { if (_childrenArranger == null) { _childrenArranger = ElementArrangerFactory.CreateChildrenArranger(_elementConfiguration); } if (_childrenArranger != null) { List <ICodeElement> children = new List <ICodeElement>(codeElement.Children); codeElement.ClearChildren(); foreach (ICodeElement childElement in children) { ArrangeChildElement(codeElement, childElement); } // // For condition directives, arrange the children of each node in the list. // ConditionDirectiveElement conditionDirective = codeElement as ConditionDirectiveElement; if (conditionDirective != null) { // // Skip the first instance since we've already arranged those child elements. // conditionDirective = conditionDirective.ElseCondition; } while (conditionDirective != null) { children = new List <ICodeElement>(conditionDirective.Children); conditionDirective.ClearChildren(); foreach (ICodeElement childElement in children) { ArrangeChildElement(conditionDirective, childElement); } conditionDirective = conditionDirective.ElseCondition; } } } if (_inserter == null) { _inserter = CreateElementInserter( _elementConfiguration.ElementType, _elementConfiguration.SortBy, _elementConfiguration.GroupBy, _parentConfiguration); } // For Type elements, if interdependent static fields are present, correct their // ordering. TypeElement typeElement = codeElement as TypeElement; if (typeElement != null && (typeElement.Type == TypeElementType.Class || typeElement.Type == TypeElementType.Structure || typeElement.Type == TypeElementType.Module)) { CorrectStaticFieldDependencies(typeElement); } _inserter.InsertElement(parentElement, codeElement); }
/// <summary> /// Arranges the element in within the code tree represented in the specified /// builder. /// </summary> /// <param name="parentElement">The parent element.</param> /// <param name="codeElement">The code element.</param> public virtual void ArrangeElement(ICodeElement parentElement, ICodeElement codeElement) { if (codeElement.Children.Count > 0) { if (_childrenArranger == null) { _childrenArranger = ElementArrangerFactory.CreateChildrenArranger(_elementConfiguration); } if (_childrenArranger != null) { List<ICodeElement> children = new List<ICodeElement>(codeElement.Children); codeElement.ClearChildren(); foreach (ICodeElement childElement in children) { ArrangeChildElement(codeElement, childElement); } // // For condition directives, arrange the children of each node in the list. // ConditionDirectiveElement conditionDirective = codeElement as ConditionDirectiveElement; if (conditionDirective != null) { // // Skip the first instance since we've already arranged those child elements. // conditionDirective = conditionDirective.ElseCondition; } while (conditionDirective != null) { children = new List<ICodeElement>(conditionDirective.Children); conditionDirective.ClearChildren(); foreach (ICodeElement childElement in children) { ArrangeChildElement(conditionDirective, childElement); } conditionDirective = conditionDirective.ElseCondition; } } } if (_inserter == null) { _inserter = CreateElementInserter( _elementConfiguration.ElementType, _elementConfiguration.SortBy, _elementConfiguration.GroupBy, _parentConfiguration); } // For Type elements, if interdependent static fields are present, correct their // ordering. TypeElement typeElement = codeElement as TypeElement; if (typeElement != null && (typeElement.Type == TypeElementType.Class || typeElement.Type == TypeElementType.Structure || typeElement.Type == TypeElementType.Module)) { CorrectStaticFieldDependencies(typeElement); } _inserter.InsertElement(parentElement, codeElement); }