Esempio n. 1
0
        public ActionPipe(IActionPipeMap map, ActionToken actionToken, IDependencyResolver dependencyResolver)
        {
            ActionToken             = actionToken;
            this.dependencyResolver = dependencyResolver;
            Map = map;

            actions = map
                      .UsedActionTypes
                      .ToDictionary(k => k, t => (IAction)dependencyResolver.Resolve(t));

            Current = new IAction[0];

            executions = actions.Keys.ToDictionary(k => k, _ => new Queue <TimeSpan>());
        }
Esempio n. 2
0
 void Generate(
     IActionPipeMap map
     , StringBuilder buffer
     , Func <int> labelize
     , Type currentNode
     , int currentLabel
     , Predicate <Type> alreadyVisited
     , Action <Type> addVisit
     , Func <Type, string> getTokenValue)
 {
     foreach (var nextNode in map.GetNext(currentNode).Where(next => !alreadyVisited(next)))
     {
         addVisit(nextNode);
         var nextNodeLabel = labelize();
         var token         = getTokenValue(currentNode);
         buffer.AppendLine($"{currentLabel}[{currentNode.Name}] --> |{token}| {nextNodeLabel}[{nextNode.Name}]");
         Generate(map, buffer, labelize, nextNode, nextNodeLabel, alreadyVisited, addVisit, getTokenValue);
     }
 }
Esempio n. 3
0
        string Visualize(IActionPipeMap map, IEnumerable <Type> entryPoints)
        {
            var buffer = new StringBuilder();

            buffer.AppendLine(Header);

            int label = 1;

            int labelize() => label++;

            var alreadyVisited = new HashSet <Type>();
            Func <Type, string> tokenDescriptionFunction = t => GetTokenName(t);

            foreach (var currentNode in entryPoints)
            {
                buffer.AppendLine($"subgraph {currentNode.Name}");
                Generate(map, buffer, labelize, currentNode, labelize(), alreadyVisited.Contains, t => alreadyVisited.Add(t), tokenDescriptionFunction);
                buffer.AppendLine("end");
            }

            return(buffer.ToString());
        }
Esempio n. 4
0
 public string Visualize(IActionPipeMap map, Type beginAt)
 => Visualize(map, new[] { beginAt });
Esempio n. 5
0
 public string Visualize(IActionPipeMap map)
 => Visualize(map, map.GetEntryPoints());