private int Invalidate(ISlot slot) { if (slot.IsConnected) { // slot is an output of an composition op slot.DirtyFlag.Target = Invalidate(slot.GetConnection(0)); } else { Instance parent = slot.Parent; foreach (var input in parent.Inputs) { if (input.IsConnected) { if (input.IsMultiInput) { var multiInput = (IMultiInputSlot)input; int dirtySum = 0; foreach (var entry in multiInput.GetCollectedInputs()) { dirtySum += Invalidate(entry); } input.DirtyFlag.Target = dirtySum; } else { input.DirtyFlag.Target = Invalidate(input.GetConnection(0)); } } else { input.DirtyFlag.Invalidate(); } } slot.DirtyFlag.Invalidate(); } return(slot.DirtyFlag.Target); }