using Microsoft.Extensions.DependencyInjection;
public static void Main()
var serviceProvider = new ServiceCollection()
.AddSingleton<IQueueUrlProvider, QueueUrlProvider>()
Console.WriteLine(serviceProvider.GetService<IQueueUrlProvider>().QueueUrl);
public interface IQueueUrlProvider
public class QueueUrlProvider : IQueueUrlProvider
private readonly Lazy<string> _getQueueUrlLazy;
public string QueueUrl => _getQueueUrlLazy.Value;
public QueueUrlProvider()
_getQueueUrlLazy = new Lazy<string>(GetQueueUrl);
private string GetQueueUrl()