public int GetNumItemsInTree() { LazyTestDataSource lazyTestDataSource = this.m_TreeView.data as LazyTestDataSource; int result; if (lazyTestDataSource != null) { result = lazyTestDataSource.itemCounter; } else { TestDataSource testDataSource = this.m_TreeView.data as TestDataSource; if (testDataSource != null) { result = testDataSource.itemCounter; } else { result = -1; } } return(result); }