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); }
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); }
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); }
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); }
private string[] ParseLine(string line, AssemblyListOptions options) { return(line.Split(new[] { options.Separator }, StringSplitOptions.None)); }