/// <summary> /// Asynchronously reads source server information. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A <see cref="Task"/> that represents the asynchronous read operation. /// </returns> public async Task ReadSourceServerInformationAsync(CancellationToken cancellationToken) { const string sourceFiles = "/src/files/"; const int sourceFilesLength = 11; if (_file.StreamExists("srcsrv")) SourceInformation = await SrcSrvParser.ParseAsync(_file, cancellationToken); if (SourceInformation == null) { SourceInformation = new SourceInformationCollection(); foreach (var item in _file.StreamNames.Where(x => x.StartsWith(sourceFiles))) { SourceInformation.Add(new Symbols.SourceInformation(item.Substring(sourceFilesLength))); } } }
public void Rollback(SourceInformationCollection allSourceInformation) { this.PreRemoveSearchResults(false); this.RemoveSearchResults(); }
public void CheckInitialStatus(SourceInformationCollection allSourceInformation, OperationStatus status) { }
public static async Task<SourceInformationCollection> ParseAsync(TextReader reader, CancellationToken cancellationToken) { const int State_Start = 0; const int State_Ini = 1; const int State_Vars = 2; const int State_Files = 3; var vars = new Dictionary<string, SrcSrvExpression>(StringComparer.OrdinalIgnoreCase); var lineVars = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); var result = new SourceInformationCollection(); var state = State_Start; string line; while ((line = await reader.ReadLineAsync()) != null) { cancellationToken.ThrowIfCancellationRequested(); switch (state) { case State_Start: if (line.StartsWith("SRCSRV: ini")) state = State_Ini; break; case State_Ini: if (line.StartsWith("SRCSRV: variables")) state = State_Vars; break; case State_Vars: if (line.StartsWith("SRCSRV: source files")) { if (!vars.ContainsKey("SRCSRVTRG")) return null; state = State_Files; } else { var index = line.IndexOf('='); if (index > 0) { var var = ParseVariable(line.Substring(index + 1)); if (var == null) return null; vars.Add(line.Substring(0, index), var); } } break; case State_Files: var split = line.Split('*'); if (!string.IsNullOrWhiteSpace(line) && split.Length > 0) { lineVars.Clear(); for (var i = 0; i < split.Length; i++) lineVars[string.Format(CultureInfo.InvariantCulture, "VAR{0}", i + 1)] = split[i]; var trg = vars["SRCSRVTRG"].Evaluate(vars, lineVars); result.Add(new SourceInformation(split[0], trg)); } break; } } return result; }