Files
Angel6/ASP.Net Core/MVCBasics/IoC/IocContainer.cs

27 lines
809 B
C#

using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EntityFrameworkBasics
{
/// <summary>
/// A shorthand access class to get DI services with nice clean short code
/// </summary>
public static class IoC
{
public static ApplicationDBContext ApplicationDbContext => IocContainer.Provider.GetService<ApplicationDBContext>();
}
/// <summary>
/// The dependency Injection container making use of the built in .Net Core service provider
/// </summary>
public static class IocContainer
{
/// <summary>
/// The service provider for this application
/// </summary>
public static ServiceProvider Provider { get; set; }
}
}