public GH_SwitchAction(GH_SwitcherComponent component, string newUnit) : base() { if (component == null) { throw new ArgumentNullException("component"); } oldState = GH_SwitcherConnectivity.Create(component); this.newUnit = newUnit; }
public static GH_SwitcherConnectivity Create(GH_SwitcherComponent component) { GH_SwitcherConnectivity gH_SwitcherConnectivity = new GH_SwitcherConnectivity(); gH_SwitcherConnectivity.componentId = component.InstanceGuid; EvaluationUnit activeUnit = component.ActiveUnit; if (activeUnit != null) { gH_SwitcherConnectivity.noUnit = false; gH_SwitcherConnectivity.unit = activeUnit.Name; } else if (component.UnitlessExistence) { gH_SwitcherConnectivity.noUnit = true; } foreach (IGH_Param item in component.Params.Input) { GH_SwitcherParamState gH_SwitcherParamState = new GH_SwitcherParamState(0, item.InstanceGuid); gH_SwitcherConnectivity.inputs.Add(gH_SwitcherParamState); foreach (IGH_Param source in item.Sources) { gH_SwitcherParamState.Targets.Add(source.InstanceGuid); } } foreach (IGH_Param item2 in component.Params.Output) { GH_SwitcherParamState gH_SwitcherParamState2 = new GH_SwitcherParamState(GH_ParameterSide.Output, item2.InstanceGuid); gH_SwitcherConnectivity.outputs.Add(gH_SwitcherParamState2); foreach (IGH_Param recipient in item2.Recipients) { gH_SwitcherParamState2.Targets.Add(recipient.InstanceGuid); } } return(gH_SwitcherConnectivity); }