using System;
using System.Threading.Tasks;

namespace Ab.Configuration
{
	public sealed class LazyOptionsProviderAdapter<T> : IOptionsProvider<T>
	{
		private readonly Lazy<Task<T>> _options;

		public LazyOptionsProviderAdapter(IOptionsProvider<T> optionsProvider)
		{
			_options = new Lazy<Task<T>>(optionsProvider.GetOptions);
		}

		public Task<T> GetOptions()
		{
			return _options.Value;
		}
	}
}