private bool TryReadNext(string method, TargetUri targetUri, out CapturedNetworkQuery query) { if (method is null) { throw new ArgumentNullException(nameof(method)); } if (targetUri is null) { throw new ArgumentNullException(nameof(targetUri)); } var urlPair = new CaptureNetwork.StringPair { String1 = targetUri?.QueryUri?.ToString(), String2 = targetUri?.ProxyUri?.ToString(), }; if (!_captured.TryGetValue(urlPair, out var byMethod) || !byMethod.TryGetValue(method, out var queries) || queries.Count == 0) { query = default(CapturedNetworkQuery); return(false); } query = queries.Dequeue(); return(true); }
internal void SetReplayData(CapturedNetworkData data) { if (data.Operations is null) { return; } foreach (var operation in data.Operations) { if (operation.Methods is null) { continue; } var urlPair = new CaptureNetwork.StringPair { String1 = operation.QueryUrl, String2 = operation.ProxyUrl, }; if (!_captured.TryGetValue(urlPair, out var byMethod)) { byMethod = new Dictionary <string, Queue <CapturedNetworkQuery> >(Ordinal); _captured.Add(urlPair, byMethod); } foreach (var method in operation.Methods) { if (method.Queries is null) { continue; } if (!byMethod.TryGetValue(method.Method, out var queries)) { queries = new Queue <CapturedNetworkQuery>(); byMethod.Add(method.Method, queries); } foreach (var query in method.Queries) { queries.Enqueue(query); } } } }