public void SetArgumentTypes(IEnumerable <BaseType> parameterTypes) { Dictionary <int, IEnumerable <NodeInputDataPin> > oldConnections = new Dictionary <int, IEnumerable <NodeInputDataPin> >(); // Disconnect all current connections and remember them foreach (NodeOutputDataPin pin in OutputDataPins) { // Remember pins with same type as before int i = OutputDataPins.IndexOf(pin); if (i < parameterTypes.Count() && pin.PinType == parameterTypes.ElementAt(i)) { oldConnections.Add(i, new List <NodeInputDataPin>(pin.OutgoingPins)); } GraphUtil.DisconnectOutputDataPin(pin); } OutputDataPins.Clear(); foreach (BaseType paramType in parameterTypes) { AddOutputDataPin(paramType.ShortName, paramType); } foreach (var oldConn in oldConnections) { foreach (NodeInputDataPin toPin in oldConn.Value) { GraphUtil.ConnectDataPins(OutputDataPins[oldConn.Key], toPin); } } }
public override string TranslatePureFunctions() { StringBuilder builder = new StringBuilder(); builder.Append($"void {PureFunctionName}()\n"); builder.Append("{\n"); builder.Append($"{OutputDataPins.Single().VariableName} = string.Concat({idps.Single().VariableName}.Reverse());\n"); builder.Append("}\n"); return(builder.ToString()); }
public void RemoveArgument() { if (OutputDataPins.Count > 0) { NodeOutputDataPin odpToRemove = OutputDataPins.Last(); NodeInputTypePin itpToRemove = InputTypePins.Last(); GraphUtil.DisconnectOutputDataPin(odpToRemove); GraphUtil.DisconnectInputTypePin(itpToRemove); OutputDataPins.Remove(odpToRemove); InputTypePins.Remove(itpToRemove); } }
/// <summary> /// Updates the result pin's type depending on the incoming task's return type. /// </summary> private void UpdateResultPin() { // Check if the task returns a value and add or remove the result // pin depending on that. TypeSpecifier taskType = (TypeSpecifier)(TaskPin.IncomingPin?.PinType?.Value ?? TypeSpecifier.FromType <Task>()); if (taskType.GenericArguments.Count > 0) { BaseType returnType = taskType.GenericArguments[0]; if (ResultPin != null) { ResultPin.PinType.Value = returnType; // Disconnect all existing connections. // Might want them to stay connected but that requires reflection // to determine if the types are still compatible. foreach (var outgoingPin in ResultPin.OutgoingPins) { GraphUtil.DisconnectOutputDataPin(ResultPin); } } else { AddOutputDataPin("Result", returnType); } } else { // Remove existing result pin if any if (ResultPin != null) { GraphUtil.DisconnectOutputDataPin(ResultPin); OutputDataPins.Remove(ResultPin); } } }
public override string TranslateVariables() { return($"var {OutputDataPins.Single().VariableName} = default(string);\n"); }
public override string TranslateVariables() { var odp = OutputDataPins.Single(); return($"const {odp.Type.FullName} {odp.VariableName} = {value};\n"); }