Exemple #1
0
        private static string GetActualResult(string inputLines)
        {
            var tempFileName = Path.GetTempFileName();

            using (var writer = new StreamWriter(tempFileName))
                writer.Write(inputLines);

            var actualResult = GetActualResult();

            try
            {
                File.Delete(tempFileName);
            }
            catch (IOException) { }

            return(actualResult);

            string GetActualResult()
            {
                using (var reader = new StreamReader(tempFileName))
                {
                    var(graph, source, target) = DataParser.GetInputData(reader.ReadLine);
                    var resultPath = DijkstraPathFinder.GetShortestPath(graph, source, target);
                    return(DataParser.ResultGenerate(resultPath, graph));
                }
            }
        }