public TreeNode createDirectoryNode(ModelDirectory dir) { var dirNode = new TreeNode(dir.name); dirNode.Name = dir.id; if (dir.isParent()) { foreach (var child in dir.children) { dirNode.Nodes.Add(createDirectoryNode(child)); } } return(dirNode); }
private void getDirectories(DBReader reader) { ModelDirectory directory; string query = SqlQueries.getDirectories; List <string[]> directoryData = reader.readFromDB(query).getQueryDataAsStrings(); foreach (string[] row in directoryData) { directory = new ModelDirectory(); directory.parentId = row[SqlQueries.getDirectories_parentIdIndex]; directory.id = row[SqlQueries.getDirectories_directoryIdIndex]; directory.name = row[SqlQueries.getDirectories_directoryNameIndex]; if (directory.parentId == null || directory.parentId == "") { baseTreeDirectories.Add(directory); } directoryDict.Add(directory.id, directory); } assignChildren(); }
public void addChild(ModelDirectory dir) { children.Add(dir); }