当前位置: 首页>>代码示例>>C#>>正文


C# ICodeElement.ClearChildren方法代码示例

本文整理汇总了C#中ICodeElement.ClearChildren方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeElement.ClearChildren方法的具体用法?C# ICodeElement.ClearChildren怎么用?C# ICodeElement.ClearChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICodeElement的用法示例。


在下文中一共展示了ICodeElement.ClearChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ArrangeElement

        /// <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);
        }
开发者ID:MarcStan,项目名称:NArrange,代码行数:71,代码来源:ElementArranger.cs


注:本文中的ICodeElement.ClearChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。