public IQueryable <TEntity> Set <TEntity>() where TEntity : class { if (typeof(TEntity) == typeof(RootContent)) { return((IQueryable <TEntity>)Roots.AsQueryable()); } if (typeof(TEntity) == typeof(ChildContent)) { return((IQueryable <TEntity>)Roots .SelectMany(r => r.Children) .ToList() .AsQueryable()); } throw new ArgumentException(); }
private IType GetTypeFromRoslynDom() { var candidates = Roots .SelectMany(x => x.Descendants .OfType <IType>() .OfType <RoslynRDomBase>() .Where(y => y.Symbol == Symbol) ) .ToList(); var count = candidates.Count(); if (count == 1) { return(candidates.First() as IType); } else if (count > 1) { Guardian.AmbiguousType(Name); _searchFailed = true; } return(null); }
public IEnumerable <Node> GetAllNodes() { return(Roots.SelectMany(root => root.GetSubTree())); }
public void Initialize() { var allNodes = Roots?.SelectMany(r => r.DescendantsAndSelf()) ?? Array.Empty <TreeNode>(); Assignees = new SortedSet <string>(allNodes.SelectMany(n => n.Assignees)) { null }; Milestones = new SortedSet <string>(allNodes.Select(n => n.Milestone)) { null }; Releases = new SortedSet <string>(allNodes.Select(n => n.ReleaseInfo?.Release)) { null }; States = new SortedSet <string>(allNodes.Select(n => n.ReleaseInfo?.Status)) { null }; Priorities = new SortedSet <int?>(allNodes.Select(n => n.Priority)) { null }; Costs = new SortedSet <TreeNodeCost?>(allNodes.Select(n => n.Cost)) { null }; Teams = new SortedSet <string>(allNodes.SelectMany(n => n.Teams)) { null }; foreach (var parent in allNodes) { foreach (var child in parent.Children) { child.Parents.Add(parent); } parent.Children.Sort((x, y) => { var result = x.Kind.CompareTo(y.Kind); if (result != 0) { return(result); } if (x.Priority != null || y.Priority != null) { if (x.Priority == null) { return(1); } if (y.Priority == null) { return(-1); } result = x.Priority.Value.CompareTo(y.Priority.Value); if (result != 0) { return(result); } } if (x.Cost != null || y.Cost != null) { if (x.Cost == null) { return(1); } if (y.Cost == null) { return(-1); } result = -x.Cost.Value.CompareTo(y.Cost.Value); if (result != 0) { return(result); } } return(x.Title.CompareTo(y.Title)); }); } }