/// <summary> /// This method encapsulates the logic of how the tree representation of the tabular model should be structured /// </summary> protected internal IEnumerable <ITabularNamedObject> GetChildren(ITabularObjectContainer tabularObject) { IEnumerable <ITabularNamedObject> result = Enumerable.Empty <ITabularNamedObject>(); if (tabularObject is LogicalGroup group) { result = group.GetChildren().Where(o => VisibleInTree(o)); } else if (tabularObject is Model) { // If all object types should be shown, simply let the Model.GetChildren() method // return the objects needed: if (Options.HasFlag(LogicalTreeOptions.AllObjectTypes)) { return(Model.GetChildren().Where(o => VisibleInTree(o))); } // Otherwise, only show tables: else { result = Model.Tables.Where(t => VisibleInTree(t)); } } else if (tabularObject is Table table) { // Handles sorting internally: return(GetChildrenForTable(table)); } else if (tabularObject is Folder folder) { // Handles sorting internally: return(folder.GetChildrenByFolders().Where(c => VisibleInTree(c))); } else if (tabularObject is Hierarchy hierarchy) { // Always show in Ordinal order: return(hierarchy.Levels.OrderBy(l => l.Ordinal)); } else if (tabularObject is CalculationItemCollection calcItems) { // Always show in Ordinal order before name/metadata order (otherwise, drag/drop will be funky): if (Options.HasFlag(LogicalTreeOptions.OrderByName)) { return(calcItems.OrderBy(i => i.Ordinal).ThenBy(i => i.Name)); } else { return(calcItems.OrderBy(i => i.Ordinal).ThenBy(i => i.MetadataIndex)); } } else if (tabularObject is ITabularObjectContainer objContainer) { // All other types: result = objContainer.GetChildren(); } return(Options.HasFlag(LogicalTreeOptions.OrderByName) ? result.OrderBy(o => o.Name) : result); }
/// <summary> /// This method encapsulates the logic of how the tree representation of the tabular model should be structured /// </summary> protected IEnumerable GetChildren(ITabularObjectContainer tabularObject) { bool useDF = Options.HasFlag(LogicalTreeOptions.DisplayFolders); if (tabularObject is LogicalGroup) { return((tabularObject as LogicalGroup).GetChildren().Where(o => VisibleInTree(o))); } if (tabularObject is Model) { // If all object types should be shown, simply let the Model.GetChildren() method // return the objects needed: if (Options.HasFlag(LogicalTreeOptions.AllObjectTypes)) { return(Model.GetChildren().Where(o => VisibleInTree(o))); } // Otherwise, only show tables: else { return(Model.Tables.Where(t => VisibleInTree(t))); } } if (tabularObject is Table) { var table = tabularObject as Table; if (useDF) { var rootFolder = Folder.CreateFolder(table, ""); return(rootFolder.GetChildrenByFolders().Where(c => VisibleInTree(c))); } else { return(table.GetChildren().Where(c => VisibleInTree(c))); } } if (tabularObject is Folder) { var folder = tabularObject as Folder; return(folder.GetChildrenByFolders().Where(c => VisibleInTree(c))); } if (tabularObject is Hierarchy) { var hier = tabularObject as Hierarchy; return(hier.Levels); } if (tabularObject is ITabularObjectContainer) { return((tabularObject as ITabularObjectContainer).GetChildren()); } return(Enumerable.Empty <TabularNamedObject>()); }
private IEnumerable <ITabularNamedObject> GetChildrenFilteredLocal(ITabularObjectContainer container) { var items = new List <ITabularNamedObject>(); try { foreach (var child in GetChildren(container)) { if (VisibleInTreeLocal(child)) { items.Add(child); } } } catch { } return(items); }
/// <summary> /// This method encapsulates the logic of how the tree representation of the tabular model should be structured /// </summary> protected internal IEnumerable <ITabularNamedObject> GetChildren(ITabularObjectContainer tabularObject) { IEnumerable <ITabularNamedObject> result = Enumerable.Empty <ITabularNamedObject>(); if (tabularObject is LogicalGroup group) { result = group.GetChildren().Where(o => VisibleInTree(o)); } else if (tabularObject is Model) { // If all object types should be shown, simply let the Model.GetChildren() method // return the objects needed: if (Options.HasFlag(LogicalTreeOptions.AllObjectTypes)) { return(Model.GetChildren().Where(o => VisibleInTree(o))); } // Otherwise, only show tables: else { result = Model.Tables.Where(t => VisibleInTree(t)); } } else if (tabularObject is Table) { // Handles sorting internally: return(GetChildrenForTable(tabularObject as Table)); } else if (tabularObject is Folder) { // Handles sorting internally: return((tabularObject as Folder).GetChildrenByFolders().Where(c => VisibleInTree(c))); } else if (tabularObject is Hierarchy) { // Never sort: return((tabularObject as Hierarchy).Levels.OrderBy(l => l.Ordinal)); } else if (tabularObject is ITabularObjectContainer) { // All other types: result = (tabularObject as ITabularObjectContainer).GetChildren(); } return(Options.HasFlag(LogicalTreeOptions.OrderByName) ? result.OrderBy(o => o.Name) : result); }
public static IEnumerable <ITabularNamedObject> GetChildrenRecursive(this ITabularObjectContainer container, bool includeSelf) { if (includeSelf) { yield return(container); } foreach (var child in container.GetChildren()) { yield return(child); if (child is ITabularObjectContainer toc) { foreach (var c in toc.GetChildrenRecursive(false)) { yield return(c); } } } }
private IEnumerable GetChildrenFilteredLocal(ITabularObjectContainer container) { return(GetChildren(container).Where(child => VisibleInTreeLocal(child))); }