ApiExamples.ExTable.GetNestedDepthOfTable C# (CSharp) Метод

GetNestedDepthOfTable() приватный статический Метод

Calculates what level a table is nested inside other tables. An integer containing the level the table is nested at. 0 = Table is not nested inside any other table 1 = Table is nested within one parent table 2 = Table is nested within two parent tables etc..
private static GetNestedDepthOfTable ( Table table ) : int
table Table
Результат int
        private static int GetNestedDepthOfTable(Table table)
        {
            int depth = 0;

            NodeType type = table.NodeType;
            // The parent of the table will be a Cell, instead attempt to find a grandparent that is of type Table
            Node parent = table.GetAncestor(type);

            while (parent != null)
            {
                // Every time we find a table a level up we increase the depth counter and then try to find an
                // ancestor of type table from the parent.
                depth++;
                parent = parent.GetAncestor(type);
            }

            return depth;
        }