#if NETFRAMEWORK using System; #endif using Microsoft.Extensions.DependencyInjection; namespace DigitalData.Core.Infrastructure #if NET ; #elif NETFRAMEWORK { #endif public class Static { private readonly static Lazy LazyServices = new Lazy(() => new ServiceCollection()); public static IServiceCollection Services => LazyProvider.IsValueCreated ? LazyServices.Value : throw new InvalidOperationException("Service collection is not available after the service provider has been built."); private static readonly Lazy LazyProvider = new Lazy(Services.BuildServiceProvider); public static IServiceProvider Provider => LazyProvider.Value; } #if NETFRAMEWORK } #endif