Skip to content

Commit

Permalink
Resolved #7474: Mark ServiceProvider properties as Obsolete in base c…
Browse files Browse the repository at this point in the history
…lasses where LazyServiceProvider is available.
  • Loading branch information
hikalkan committed Jan 26, 2021
1 parent 818ca64 commit 2816b72
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract class AbpPageModel : PageModel
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public abstract class AbpViewComponent : ViewComponent
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

protected Type ObjectMapperContext { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public abstract class AbpHub : Hub
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService<ILoggerFactory>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class ApplicationService :
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

public static string[] CommonPostfixes { get; set; } = { "AppService", "ApplicationService", "Service" };
Expand All @@ -51,7 +52,7 @@ public abstract class ApplicationService :
? provider.GetRequiredService<IObjectMapper>()
: (IObjectMapper) provider.GetRequiredService(typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));

public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService<IGuidGenerator>(SimpleGuidGenerator.Instance);
protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService<IGuidGenerator>(SimpleGuidGenerator.Instance);

protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ public abstract class DomainService : IDomainService
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }

[Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }

protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>();

public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService<IGuidGenerator>(SimpleGuidGenerator.Instance);
protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService<IGuidGenerator>(SimpleGuidGenerator.Instance);

protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();

Expand Down

0 comments on commit 2816b72

Please sign in to comment.