#if NETFRAMEWORK using System; #endif using DigitalData.Core.Abstraction.Application.Repository; using Microsoft.Extensions.DependencyInjection; namespace DigitalData.Core.Abstraction.Application #if NET ; #elif NETFRAMEWORK { #endif public static class Static { private readonly static Lazy LazyServices = new Lazy(() => new ServiceCollection()); public static IServiceCollection Services => LazyProvider.IsValueCreated ? LazyServices.Value : throw new InvalidOperationException("Services cannot be accessed after the Provider has been created."); private static readonly Lazy LazyProvider = new Lazy(Services.BuildServiceProvider); public static IServiceProvider Provider => LazyProvider.Value; public static IRepository Repository => Provider.GetRequiredService(); } public static class Static { public static IRepository Repository() => Static.Provider.GetRequiredService>(); } #if NETFRAMEWORK } #endif