///Get a list of variable names used by the current selection of the current graph in the NC Editor window. static List <string> GetUsedVariablesBySelectionParameters() { var result = new List <string>(); if (Graph.currentSelection == null) { return(result); } result.AddRange(BBParameter.GetObjectBBParameters(Graph.currentSelection).Select(p => p.name)); var assignable = Graph.currentSelection as ITaskAssignable; if (assignable != null && assignable.task != null) { result.AddRange(BBParameter.GetObjectBBParameters(assignable.task).Select(p => p.name)); if (assignable.task.agentIsOverride && !string.IsNullOrEmpty(assignable.task.overrideAgentParameterName)) { result.Add(assignable.task.overrideAgentParameterName); } var taskActionList = assignable.task as ActionList; if (taskActionList != null) { foreach (var t in taskActionList.actions) { result.AddRange(BBParameter.GetObjectBBParameters(t).Select(p => p.name)); if (!string.IsNullOrEmpty(t.overrideAgentParameterName)) { result.Add(t.overrideAgentParameterName); } } } var taskConditionList = assignable.task as ConditionList; if (taskConditionList != null) { foreach (var t in taskConditionList.conditions) { result.AddRange(BBParameter.GetObjectBBParameters(t).Select(p => p.name)); if (!string.IsNullOrEmpty(t.overrideAgentParameterName)) { result.Add(t.overrideAgentParameterName); } } } } return(result); }
static List <string> GetUsedVariablesBySelectionParameters(object target) { var result = new List <string>(); if (target == null) { return(result); } result.AddRange(BBParameter.GetObjectBBParameters(target).Select(p => p.name)); var task = target as Task; if (task != null) { result.AddRange(BBParameter.GetObjectBBParameters(task).Select(p => p.name)); if (!string.IsNullOrEmpty(task.overrideAgentParameterName)) { result.Add(task.overrideAgentParameterName); } } var taskActionList = target as ActionList; if (taskActionList != null) { for (var i = 0; i < taskActionList.actions.Count; i++) { var t = taskActionList.actions[i]; result.AddRange(BBParameter.GetObjectBBParameters(t).Select(p => p.name)); if (!string.IsNullOrEmpty(t.overrideAgentParameterName)) { result.Add(t.overrideAgentParameterName); } } } var taskConditionList = target as ConditionList; if (taskConditionList != null) { for (var i = 0; i < taskConditionList.conditions.Count; i++) { var t = taskConditionList.conditions[i]; result.AddRange(BBParameter.GetObjectBBParameters(t).Select(p => p.name)); if (!string.IsNullOrEmpty(t.overrideAgentParameterName)) { result.Add(t.overrideAgentParameterName); } } } var subContainer = target as ISubTasksContainer; if (subContainer != null) { var subTasks = subContainer.GetTasks(); for (var i = 0; i < subTasks.Length; i++) { result.AddRange(GetUsedVariablesBySelectionParameters(subTasks[i])); } } var assignable = target as ITaskAssignable; if (assignable != null && assignable.task != null) { result.AddRange(GetUsedVariablesBySelectionParameters(assignable.task)); } return(result); }