Rosetta.Translation.NestedElementTranslationUnit.IncrementNestingLevel C# (CSharp) Method

IncrementNestingLevel() public static method

Utility method used to safely increment the nesting level of an ITranslationUnit only in case it supports nesting level.
This will cause translationUnit to be checked. In case it supports nestin level, then its nesting level is changed in order to have the nesting level of parentTranslationUnit + 1.
public static IncrementNestingLevel ( ITranslationUnit translationUnit, ITranslationUnit parentTranslationUnit ) : void
translationUnit ITranslationUnit The whose nesting level should be incremented.
parentTranslationUnit ITranslationUnit The which is supposed to be the parent.
return void
        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;
        }