Created
August 24, 2012 13:18
-
-
Save jeremyiverson/3450451 to your computer and use it in GitHub Desktop.
Colectica SDK: Output hierarchical codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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