コード例 #1
0
        public static ChangelogEntry?ReadChangeLogEntry(PeekingStreamReader reader)
        {
            var version = string.Empty;
            var supportedGameVersions = Array.Empty <string>();
            var description           = string.Empty;

            var    builder = new StringBuilder();
            string?line;

            while ((line = reader.PeekLine()) != null)
            {
                switch (line)
                {
                case { } str when str.StartsWith("Version:"):
                    version = line.Replace("Version:", "").Trim();

                    reader.ReadLine();
                    continue;

                case { } str when str.StartsWith("Game Versions:"):
                    supportedGameVersions = line.Replace("Game Versions:", "").Trim().Split(',', StringSplitOptions.RemoveEmptyEntries);

                    reader.ReadLine();
                    continue;

                case { } str when str.StartsWith("-"):
                    description = builder.ToString().Trim('\r', '\n');

                    return(new ChangelogEntry(version, supportedGameVersions, description));

                default:
                    builder.AppendLine(line);
                    reader.ReadLine();
                    continue;
                }
            }

            return(null);
        }
コード例 #2
0
        public static IEnumerable <ChangelogEntry> GetChangelogEntries(Stream stream)
        {
            var reader = new PeekingStreamReader(stream);

            string?line;

            while ((line = reader.PeekLine()) != null)
            {
                if (line.StartsWith("-"))
                {
                    reader.ReadLine();
                    var changelogEntry = ReadChangeLogEntry(reader);
                    if (changelogEntry != null)
                    {
                        yield return(changelogEntry);
                    }
                }
                else
                {
                    reader.ReadLine();
                }
            }
        }