public Anchor <EntityType> GetAnchor(string LinkToMatch) { if (LinkToMatch.StartsWith("Input")) { string LinkName = LinkToMatch.Substring(5); foreach (Anchor <EntityType> CurrentAnchor in Inputs) { if (CurrentAnchor.GetLabelText() == LinkName) { return(CurrentAnchor); } } } else if (LinkToMatch.StartsWith("Output")) { string LinkName = LinkToMatch.Substring(6); foreach (Anchor <EntityType> CurrentAnchor in Outputs) { if (CurrentAnchor.GetLabelText() == LinkName) { return(CurrentAnchor); } } } return(null); }
public virtual void UpdateAnchors() { if (WrappedInstance != null) { WrappedInstance.CreateStaticNodesIfNotPresent(); } List <Anchor <EntityType> > DeletedList = new List <Anchor <EntityType> >(); DeletedList.AddRange(Inputs); foreach (EntityLink <EntityType> InputLink in GetInputEvents()) { bool bHasAnchor = false; foreach (Anchor <EntityType> CurrentAnchor in Inputs) { if (CurrentAnchor.GetLabelText() == InputLink.Name) { bHasAnchor = true; DeletedList.Remove(CurrentAnchor); } } if (!bHasAnchor) { Anchor <EntityType> InputAnchor = new Anchor <EntityType>(InputLink.Name, GetAnchorText(InputLink), new Anchor <EntityType> .AnchorType(true), this); Inputs.Add(InputAnchor); } } foreach (Anchor <EntityType> DeletedItem in DeletedList) { DeletedItem.CleanupBeforeRemoval(); Owner.BreakAllConnectionsForAnchor(DeletedItem); Inputs.Remove(DeletedItem); } DeletedList.Clear(); DeletedList.AddRange(Outputs); foreach (EntityLink <EntityType> OutputLink in GetOutputEvents()) { bool bHasAnchor = false; foreach (Anchor <EntityType> CurrentAnchor in Outputs) { if (CurrentAnchor.GetLabelText() == OutputLink.Name) { bHasAnchor = true; DeletedList.Remove(CurrentAnchor); } } if (!bHasAnchor) { Anchor <EntityType> OutputAnchor = new Anchor <EntityType>(OutputLink.Name, GetAnchorText(OutputLink), new Anchor <EntityType> .AnchorType(false), this); Outputs.Add(OutputAnchor); } } foreach (Anchor <EntityType> DeletedItem in DeletedList) { DeletedItem.CleanupBeforeRemoval(); Owner.BreakAllConnectionsForAnchor(DeletedItem); Outputs.Remove(DeletedItem); } DeletedList.Clear(); }