示例#1
0
        public static List <IGH_ActiveObject> SourcesRecursive(IGH_Param p, List <IGH_ActiveObject> possibleObjects)
        {
            List <IGH_ActiveObject> results = new List <IGH_ActiveObject>();
            var sources = possibleObjects.Where(po => p.DependsOn(po));

            var ParamSources = sources.Where(s => s is IGH_Param).Cast <IGH_Param>().ToList();

            var ComponentSources = sources.Where(s => s is IGH_Component).Cast <IGH_Component>().ToList();

            foreach (IGH_Param param in ParamSources)
            {
                results.Add(param);
                results.AddRange(SourcesRecursive(param, possibleObjects));
            }

            foreach (IGH_Component component in ComponentSources)
            {
                results.Add(component);
                component.Params.Input.ForEach(input => results.AddRange(SourcesRecursive(input, possibleObjects)));
            }
            return(results);
        }