public async Task <CheckResultData> ExecuteAsync(string url, string substring, CancellationToken token) { return(await _check.ExecuteAsync( url, async (stream, innerToken) => { using (var reader = new StreamReader(stream)) { var content = await reader.ReadToEndAsync(); if (!content.Contains(substring)) { return new CheckResultData { Type = CheckResultType.Failure, Message = $"URL: {url}{Environment.NewLine}Response body did not contain '{substring}'." }; } return new CheckResultData { Type = CheckResultType.Success }; } }, token)); }
public async Task <CheckResultData> ExecuteAsync(string url, Func <JToken, CheckResultData> process, CancellationToken token) { return(await _check.ExecuteAsync( url, (stream, innerToken) => { using (var streamReader = new StreamReader(stream)) using (var jsonTextReader = new JsonTextReader(streamReader)) { jsonTextReader.DateParseHandling = DateParseHandling.None; var jToken = JToken.Load(jsonTextReader); var result = process(jToken); return Task.FromResult(result); } }, token)); }