Example #1
0
        public static IEnumerable <GitHubObject> Parse(StreamReader stream)
        {
            using CsvReader csv = new CsvReader(stream, new CsvConfiguration(CultureInfo.InvariantCulture));
            while (csv.Read())
            {
                // the first field is the type of the object
                GitHubObjectType type = Enum.Parse <GitHubObjectType>(csv.GetField(0));

                // the remaining field are properties of that object
                yield return(CreateObject(type, csv.Context.Parser.Record.Skip(1).ToArray()));
            }
        }
Example #2
0
        private static GitHubObject CreateObject(GitHubObjectType type, string[] entries)
        {
            switch (type)
            {
            case GitHubObjectType.Milestone:
                return(new Milestone(entries));

            case GitHubObjectType.Label:
                return(new Label(entries));

            default:
                throw new InvalidOperationException($"Type {type} is not supported.");
            }
        }
Example #3
0
        public static IEnumerable <GitHubObject> Parse(StreamReader stream)
        {
            string line; int lineCount = 0;

            while ((line = stream.ReadLine()) != null)
            {
                lineCount++;
                // Parse the type, title and description
                string[] entries = line.Split(',', StringSplitOptions.None); // we want empty entries

                if (entries.Length < 3)
                {
                    Colorizer.WriteLine("[Yellow!Warning] Line {0} too short!", lineCount);
                }

                // the type of the object
                GitHubObjectType type = Enum.Parse <GitHubObjectType>(entries[0]);

                yield return(CreateObject(type, entries.Skip(1).ToArray()));
            }
        }