Beispiel #1
0
        public int RunStuff()
        {
            var graph = new UpdateGraph <int>();

            for (var i = 0; i < Updaters; ++i)
            {
                graph.AddUpdate(new[] { i }, DoNothing, new[] { i + 1 });
            }

            graph.Trigger(0);
            return(Updaters);
        }
Beispiel #2
0
        private Dictionary <string, UpdateStep> GetUpdateGraphFromString(UpdateGraph <string> graph, string str)
        {
            var dictionary  = new Dictionary <string, UpdateStep>();
            var provider    = new UpdateOrderProvider();
            var updateNodes = str.Split(' ');

            foreach (var node in updateNodes)
            {
                (var name, var triggering, var triggered, var actual) = ParseUpdateStep(node);

                if (!dictionary.TryGetValue(name, out var step))
                {
                    step = new UpdateStep(provider, name);
                    dictionary.Add(name, step);
                }
                foreach (var trigger in actual)
                {
                    step.Triggers.Add(trigger);
                }
                graph.AddUpdate(triggering, new UpdateFunction <string>(step.Update, name), triggered);
            }

            return(dictionary);
        }