public IEnumerable <PObject> GetObjectChildren(Guid id, ChildrenType type) { CheckApi(); var parent = GetObject(id); if (parent == null) { throw new Exception("Object not found"); } var childIds = GetChildrenByType(parent, type); var res = new List <PObject>(); if (childIds.Any()) { var children = _serverApi.GetObjects(childIds); res = children.Select(o => new PObject(o, _metadata, _people)).ToList(); res.Sort(new ObjectComparer()); } var parentType = GetType(parent.TypeId); if (parentType.IsMountable && type != ChildrenType.Storage) { res.Insert(0, new SourcePObject(parent, _metadata, _people, this)); } return(res); }
private Guid[] GetChildrenByType(DObject obj, ChildrenType type) { var childIds = new Guid[0]; switch (type) { case ChildrenType.All: childIds = obj.Children.Select(c => c.ObjectId).ToArray(); break; case ChildrenType.ListView: childIds = obj.GetChildrenForListView(this).ToArray(); break; case ChildrenType.TreeView: break; case ChildrenType.Storage: childIds = obj.GetChildrenForPilotStorage(this).ToArray(); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(childIds); }