public PathFinderTxtHandlerTest() { var services = new ServiceCollection(); InjectorBootStrapper.RegisterServices(services); _shortestPathFinder = services.BuildServiceProvider().GetService <IShortestPathFinderService>(); }
public static string GeneratePathsText(string encomendas, IShortestPathFinderService shortestPathFinder) { var lines = new List <string>(); lock (lockObj) { foreach (var line in encomendas.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries)) { var nodeIds = line.Split(" ", StringSplitOptions.RemoveEmptyEntries) .Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); var node1Id = nodeIds[0]; var node2Id = nodeIds[1]; var nodesPath = shortestPathFinder.FindShortestPath(nodes[node1Id], nodes[node2Id]); lines.Add(GeneratePathTextLine(nodesPath)); } } return(string.Join(Environment.NewLine, lines)); }
/// <summary> /// Registra os trechos disponíveis /// </summary> public FindShortestPathController(IShortestPathFinderService shortestPathFinder) { _shortestPathFinder = shortestPathFinder; }