public void AddUpdate(IEnumerable <TTrigger> incomming, UpdateFunction <TTrigger> function, IEnumerable <TTrigger> potentialTriggers) { if (!UpdaterToNodeDictionary.TryGetValue(function.Updater, out var node)) { node = new UpdateNode <TTrigger>(function); UpdaterToNodeDictionary.Add(function.Updater, node); } node.NodeRegisterCount++; node.AddName(function.Name); foreach (var inc in incomming) { if (node.AddIncomming(inc)) { TriggerToTriggeredNodesDictionary.Add(inc, node); } } foreach (var inc in potentialTriggers) { if (node.AddOutgoing(inc)) { TriggerToTriggeringNodesDictionary.Add(inc, node); } } }
public void RemoveUpdate(UpdateFunction <TTrigger> function) { if (!UpdaterToNodeDictionary.TryGetValue(function.Updater, out var node)) { return; } node.NodeRegisterCount--; if (node.NodeRegisterCount > 0) { return; } foreach (var trigger in node.IncommingTriggers) { TriggerToTriggeredNodesDictionary.Remove(trigger, node); } foreach (var trigger in node.OutgoingTriggers) { TriggerToTriggeringNodesDictionary.Remove(trigger, node); } }