Skip to content

Instantly share code, notes, and snippets.

@thinkt4nk
Created March 21, 2011 14:11
Show Gist options
  • Save thinkt4nk/879498 to your computer and use it in GitHub Desktop.
Save thinkt4nk/879498 to your computer and use it in GitHub Desktop.
public Dictionary<string,Object> getChildrenRecursive()
{
Dictionary<string,Object> categoryDictionary = new Dictionary<string, Object>();
Dictionary<string, Object>[] children;
if (this.hasChildren())
{
// Get child nodes
Duke.CategoryDataTable ChildTable = this.CategoryAdapter.GetAllByParentCategory(categoryCode);
children = new Dictionary<string, Object>[ChildTable.Rows.Count];
for (int i = 0; i < ChildTable.Rows.Count; i++)
{
BAL.Category ChildCategory = new BAL.Category((String)ChildTable.Rows[i]["categoryCode"]);
children[i] = ChildCategory.getChildrenRecursive();
}
}
else
{
children = new Dictionary<string, Object>[0];
}
categoryDictionary.Add(this.categoryCode,children);
return categoryDictionary;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment