// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections; using System.Collections.Generic; namespace Microsoft.Extensions.Diagnostics.HealthChecks { internal class HealthCheckLogScope : IReadOnlyList> { public string HealthCheckName { get; } int IReadOnlyCollection>.Count { get; } = 1; KeyValuePair IReadOnlyList>.this[int index] { get { if (index == 0) { return new KeyValuePair(nameof(HealthCheckName), HealthCheckName); } throw new ArgumentOutOfRangeException(nameof(index)); } } /// /// Creates a new instance of with the provided name. /// /// The name of the health check being executed. public HealthCheckLogScope(string healthCheckName) { HealthCheckName = healthCheckName; } IEnumerator> IEnumerable>.GetEnumerator() { yield return new KeyValuePair(nameof(HealthCheckName), HealthCheckName); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable>)this).GetEnumerator(); } } }