static void CreateLinkAnchor(BaseGraph graph, BaseGraphCommand command, string inputCommand) { BaseNode fromNode, toNode; GetNodes(graph, command, out fromNode, out toNode, inputCommand); var fromAnchorFields = fromNode.outputAnchorFields; var toAnchorFields = toNode.inputAnchorFields; if (command.fromAnchorIndex < 0 || command.fromAnchorIndex >= fromAnchorFields.Count) { throw new InvalidOperationException("Anchor " + command.fromAnchorIndex + " out of range in node: " + fromNode); } if (command.toAnchorIndex < 0 || command.toAnchorIndex >= toAnchorFields.Count) { throw new InvalidOperationException("Anchor " + command.fromAnchorIndex + " out of range in node: " + toNode); } var fromAnchorField = fromAnchorFields[command.fromAnchorIndex]; var toAnchorField = toAnchorFields[command.toAnchorIndex]; Anchor fromAnchor, toAnchor; FindAnchors(fromAnchorField, toAnchorField, out fromAnchor, out toAnchor); graph.SafeCreateLink(fromAnchor, toAnchor, false); }
static void CreateLinkAnchorName(BaseGraph graph, BaseGraphCommand command, string inputCommand) { BaseNode fromNode, toNode; GetNodes(graph, command, out fromNode, out toNode, inputCommand); var fromAnchorField = fromNode.outputAnchorFields.Find(af => af.fieldName == command.fromAnchorFieldName); var toAnchorField = toNode.inputAnchorFields.Find(af => af.fieldName == command.toAnchorFieldName); if (fromAnchorField == null) { throw new InvalidOperationException("Anchor " + command.fromAnchorFieldName + " not found in node: " + fromNode); } if (toAnchorField == null) { throw new InvalidOperationException("Anchor " + command.toAnchorFieldName + " not found in node: " + toNode); } Anchor fromAnchor, toAnchor; FindAnchors(fromAnchorField, toAnchorField, out fromAnchor, out toAnchor); graph.SafeCreateLink(fromAnchor, toAnchor, false); }