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); }
void Seek(long position, SeekOrigin origin) { switch (origin) { case SeekOrigin.Begin: position = CurrentAnchor.GetAbsolute(position); break; case SeekOrigin.Current: position = AbsolutePosition + position; break; case SeekOrigin.End: position = CurrentAnchor.End - position; break; } if (position < CurrentAnchor.Start) { position = CurrentAnchor.Start; } else if (position > CurrentAnchor.End && !mStream.CanWrite) { position = CurrentAnchor.End; } mStream.Seek(position, SeekOrigin.Begin); }
public void Back() { AbsolutePosition = CurrentAnchor.Pop(); }
public void Keep() { CurrentAnchor.Push(AbsolutePosition); }
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(); }