public static IEnumerable <BaseShapeViewModel> GetAllShapes(this ProjectContainerViewModel project) { return(project?.Documents .SelectMany(d => d.Pages) .SelectMany(c => c.Layers) .SelectMany(l => l.Shapes)); }
public static IEnumerable <T> GetAllShapes <T>(this ProjectContainerViewModel project) { var shapes = project?.Documents .SelectMany(d => d.Pages) .SelectMany(c => c.Layers) .SelectMany(l => l.Shapes); return(shapes.GetAllShapes()?.Where(s => s is T).Cast <T>()); }