Class describing nested elements.
示例#1
0
        /// <summary>
        /// Utility method used to safely increment the nesting level of an <see cref="ITranslationUnit"/> only in case it supports
        /// nesting level.
        /// </summary>
        /// <param name="translationUnit">The <see cref="ITranslationUnit"/> whose nesting level should be incremented.</param>
        /// <param name="parentTranslationUnit">The <see cref="ITranslationUnit"/> which is supposed to be the parent.</param>
        /// <remarks>
        /// This will cause <paramref name="translationUnit"/> to be checked. In case it supports nestin level, then its
        /// nesting level is changed in order to have the nesting level of <paramref name="parentTranslationUnit"/> + 1.
        /// </remarks>
        public static void IncrementNestingLevel(ITranslationUnit translationUnit, ITranslationUnit parentTranslationUnit)
        {
            NestedElementTranslationUnit nestedTranslationUnit       = translationUnit as NestedElementTranslationUnit;
            NestedElementTranslationUnit nestedParentTranslationUnit = parentTranslationUnit as NestedElementTranslationUnit;

            if (nestedTranslationUnit == null || nestedParentTranslationUnit == null)
            {
                return;
            }

            nestedTranslationUnit.NestingLevel = nestedParentTranslationUnit.NestingLevel + 1;
        }
 private static void TestInitialNestingLevel(NestedElementTranslationUnit translationUnit)
 {
     Assert.AreEqual(0, translationUnit.NestingLevel, "At the beginning, nesting level should be 0!");
 }
 private static void TestNestingLevels(NestedElementTranslationUnit parent, NestedElementTranslationUnit child)
 {
     Assert.AreEqual(parent.NestingLevel + 1, child.NestingLevel, "Nested translation unit should have +1 nesting level!");
 }
 /// <summary>
 /// Copy initializes a new instance of the <see cref="NestedElementTranslationUnit"/>.
 /// </summary>
 /// <param name="other"></param>
 /// <remarks>
 /// For testability.
 /// </remarks>
 protected NestedElementTranslationUnit(NestedElementTranslationUnit other)
 {
     this.nestingLevel = other.nestingLevel;
     this.formatter = other.formatter;
     this.formatterProvider = other.formatterProvider;
 }
示例#5
0
 /// <summary>
 /// Copy initializes a new instance of the <see cref="NestedElementTranslationUnit"/>.
 /// </summary>
 /// <param name="other"></param>
 /// <remarks>
 /// For testability.
 /// </remarks>
 protected NestedElementTranslationUnit(NestedElementTranslationUnit other)
 {
     this.nestingLevel      = other.nestingLevel;
     this.formatter         = other.formatter;
     this.formatterProvider = other.formatterProvider;
 }