forked from dnnsoftware/Dnn.Platform
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes dnnsoftware#5646
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
DNN Platform/DotNetNuke.DependencyInjection/LazyWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
namespace DotNetNuke.DependencyInjection; | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
/// <summary>A <see cref="Lazy{T}"/> wrapper which allows requesting <see cref="Lazy{T}"/> via dependency injection and delaying instantiation.</summary> | ||
/// <typeparam name="T">The type of service to conditionally instantiate.</typeparam> | ||
public class LazyWrapper<T> : Lazy<T> | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="LazyWrapper{T}"/> class.</summary> | ||
/// <param name="serviceProvider">The DI container.</param> | ||
public LazyWrapper(IServiceProvider serviceProvider) | ||
: base(serviceProvider.GetService<T>) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters