Пример #1
0
        private bool TryReadEntry(Func <string> readNonEmptyLine, AssemblyListOptions options, string[] headers, out AssemblyListEntry entry)
        {
            entry = null;

            var line = readNonEmptyLine();

            if (line == null)
            {
                return(false);
            }

            var parsedLine = ParseLine(line, options);

            // TODO: Should we use headers? Investigate available lists for header-consistency

            if (parsedLine.Length != options.NumberOfFields)
            {
                return(false);
            }

            entry = new AssemblyListEntry
            {
                Assembly        = parsedLine[0],
                FileVersion     = parsedLine[1],
                AssemblyVersion = parsedLine[2]
            };
            return(true);
        }
Пример #2
0
        private bool TryReadHeader(Func <string> readNonEmptyLine, out string[] headers, out AssemblyListOptions options)
        {
            headers = null;
            options = null;

            var line = readNonEmptyLine();

            while (line != null)
            {
                if (TryParseOptions(line, out options))
                {
                    line = readNonEmptyLine();
                }

                if (line == null)
                {
                    return(false);
                }

                if (options == null)
                {
                    var separator = GuessSeparator(line);

                    if (separator == null)
                    {
                        line = readNonEmptyLine();
                        continue;
                    }

                    options = new AssemblyListOptions
                    {
                        Separator = GuessSeparator(line)
                    };
                }

                headers = ParseLine(line, options);
                options.NumberOfFields = headers.Length;

                return(true);
            }

            return(false);
        }
Пример #3
0
        private bool TryReadHeader(Func <string> readNonEmptyLine, out string[] headers, out AssemblyListOptions options)
        {
            headers = null;
            options = null;

            var line = readNonEmptyLine();

            if (line == null)
            {
                return(false);
            }

            if (TryParseOptions(line, out options))
            {
                line = readNonEmptyLine();
            }

            if (line == null)
            {
                return(false);
            }

            if (options == null)
            {
                var separator = GuessSeparator(line);

                if (separator == null)
                {
                    // TODO: Log
                    return(false);
                }

                options = new AssemblyListOptions
                {
                    Separator = GuessSeparator(line)
                };
            }

            headers = ParseLine(line, options);
            return(true);
        }
Пример #4
0
        private bool TryParseOptions(string line, out AssemblyListOptions options)
        {
            options = null;

            if (string.IsNullOrEmpty(line))
            {
                return(false);
            }

            if (!line.StartsWith("sep=") || line.Length < "sep=".Length + 1)
            {
                return(false);
            }

            var separator = line.Substring("sep=".Length);

            options = new AssemblyListOptions
            {
                Separator = separator
            };

            return(true);
        }
Пример #5
0
 private string[] ParseLine(string line, AssemblyListOptions options)
 {
     return(line.Split(new[] { options.Separator }, StringSplitOptions.None));
 }