Skip to content

Instantly share code, notes, and snippets.

@jeremyiverson
Created August 24, 2012 13:18
Show Gist options
  • Save jeremyiverson/3450451 to your computer and use it in GitHub Desktop.
Save jeremyiverson/3450451 to your computer and use it in GitHub Desktop.
Colectica SDK: Output hierarchical codes
public void OutputAllCodesAndCategoriesHierarchical(CodeScheme codeList)
{
foreach (Code code in codeList.Codes)
{
OutputCode(code, 1);
}
}
void OutputCode(Code code, int level)
{
// Lines will look like this:
// 1 Category
// 1.2 Category
// 1.2.3 Category
// 2 Category
// Add a tab for each level.
string tabs = "";
for (int i = 0; i < level - 1; i++) tabs += "\t";
Console.WriteLine(string.Format("{0}{1}: {2}", tabs, code.Value, code.Category.DisplayLabel));
foreach (Code child in code.ChildCodes)
{
OutputCode(child, level + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment