Esempio n. 1
0
        private static IEnumerable <IImporter> PathToIImporter(string input)
        {
            // Remove preceding and seceding quotes from path.
            input = input.TrimStart('"').TrimEnd('"');

            if (string.IsNullOrWhiteSpace(input))
            {
                throw new ArgumentException("Input path cannot be null or whitespace.", nameof(input));
            }

            // Correct paths
            if (!Path.IsPathRooted(input))
            {
                input = Path.GetFullPath(input);
            }

            if (Directory.Exists(input) && input.Contains(Path.DirectorySeparatorChar + "statink"))
            {
                foreach (var file in Directory.EnumerateFiles(input))
                {
                    if (StatInkReader.AcceptsInput(file))
                    {
                        yield return(new StatInkReader(file));
                    }
                }
            }
            else if (!File.Exists(input))
            {
                Console.WriteLine($"Input does not exist on disk. Remote is not currently supported ({input}).");
            }
            else if (TwitterReader.AcceptsInput(input))
            {
                yield return(new TwitterReader(input));
            }
            else if (SendouReader.AcceptsInput(input))
            {
                yield return(new SendouReader(input));
            }
            else if (TSVReader.AcceptsInput(input))
            {
                yield return(new TSVReader(input));
            }
            else if (LUTIJsonReader.AcceptsInput(input))
            {
                yield return(new LUTIJsonReader(input));
            }
            else if (BattlefyJsonReader.AcceptsInput(input))
            {
                yield return(new BattlefyJsonReader(input));
            }
            else
            {
                throw new NotImplementedException("File extension not recognised or supported.");
            }
        }