/// <summary> /// Constructs a new <see cref="TraceContext"/> using the specified invocation ID and target <see cref="ITraceSink"/> /// </summary> /// <param name="invocationId">The ID of the invocation represented in this <see cref="TraceContext"/></param> /// <param name="sink">The <see cref="ITraceSink"/> to write trace events to</param> public TraceContext(string invocationId, ITraceSink sink) { Guard.NotNull(invocationId, "invocationId"); // String.Empty is OK and indicates no invocationId is available. Guard.NotNull(sink, "sink"); _invocationId = invocationId; _sink = sink; }
public NuGetRepository(Uri url, ITraceSink trace) { Guard.NotNull(url, "url"); Guard.NotNull(trace, "trace"); Url = url; _trace = trace; _rootClient = new HttpClient(new HttpClientHandler()); }
/// <summary> /// Constructs a new <see cref="ServiceInvocationContext"/> using the specified <see cref="HttpClient"/>, <see cref="ITraceSink"/>, base URL and <see cref="CancellationToken"/>. /// </summary> /// <param name="httpClient">The <see cref="HttpClient"/> object to use to make Http Requests.</param> /// <param name="trace">The <see cref="ITraceSink"/> object to write trace events to.</param> /// <param name="baseUrl">The base URL of the <see cref="NuGetRepository"/> associated with this invocation.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to check for cancellation.</param> public ServiceInvocationContext(HttpClient httpClient, ITraceSink trace, Uri baseUrl, CancellationToken cancellationToken) { Guard.NotNull(httpClient, "httpClient"); Guard.NotNull(trace, "trace"); Guard.NotNull(baseUrl, "baseUrl"); InvocationId = Tracing.GetNextInvocationId().ToString(CultureInfo.InvariantCulture); _client = httpClient; Trace = new TraceContext(InvocationId, trace); BaseUrl = baseUrl; CancellationToken = cancellationToken; Trace.Start(); }