@@ -9,40 +9,51 @@ namespace DotNetNuke.ComponentModel
99 using System . Diagnostics . CodeAnalysis ;
1010
1111 using DotNetNuke . Collections . Internal ;
12+ using DotNetNuke . Common ;
1213
1314 public class SimpleContainer : AbstractContainer , IDisposable
1415 {
1516 private readonly string name ;
17+ private readonly IServiceProvider serviceProvider ;
1618 private readonly ComponentBuilderCollection componentBuilders = new ComponentBuilderCollection ( ) ;
17-
1819 private readonly SharedDictionary < string , IDictionary > componentDependencies = new SharedDictionary < string , IDictionary > ( ) ;
19-
2020 private readonly ComponentTypeCollection componentTypes = new ComponentTypeCollection ( ) ;
21-
2221 private readonly SharedDictionary < Type , string > registeredComponents = new SharedDictionary < Type , string > ( ) ;
2322
2423 /// <summary>Initializes a new instance of the <see cref="SimpleContainer"/> class.</summary>
24+ [ Obsolete ( "Deprecated in DotNetNuke 10.2.2. Please use overload with IServiceProvider. Scheduled removal in v12.0.0." ) ]
2525 public SimpleContainer ( )
26- : this ( $ "Container_{ Guid . NewGuid ( ) } ")
26+ : this ( Globals . DependencyProvider )
27+ {
28+ }
29+
30+ /// <summary>Initializes a new instance of the <see cref="SimpleContainer"/> class.</summary>
31+ /// <param name="serviceProvider">The DI container scope.</param>
32+ public SimpleContainer ( IServiceProvider serviceProvider )
33+ : this ( $ "Container_{ Guid . NewGuid ( ) } ", serviceProvider )
2734 {
2835 }
2936
3037 /// <summary>Initializes a new instance of the <see cref="SimpleContainer"/> class.</summary>
3138 /// <param name="name">The container name.</param>
39+ [ Obsolete ( "Deprecated in DotNetNuke 10.2.2. Please use overload with IServiceProvider. Scheduled removal in v12.0.0." ) ]
3240 public SimpleContainer ( string name )
41+ : this ( name , Globals . DependencyProvider )
3342 {
34- this . name = name ;
3543 }
3644
37- /// <inheritdoc />
38- public override string Name
45+ /// <summary>Initializes a new instance of the <see cref="SimpleContainer"/> class.</summary>
46+ /// <param name="name">The container name.</param>
47+ /// <param name="serviceProvider">The DI container scope.</param>
48+ public SimpleContainer ( string name , IServiceProvider serviceProvider )
3949 {
40- get
41- {
42- return this . name ;
43- }
50+ this . name = name ;
51+ this . serviceProvider = serviceProvider ;
4452 }
4553
54+ /// <inheritdoc />
55+ public override string Name => this . name ;
56+
4657 /// <inheritdoc />
4758 [ SuppressMessage ( "Microsoft.Naming" , "CA1725:ParameterNamesShouldMatchBaseDeclaration" , Justification = "Breaking change" ) ]
4859 public override void RegisterComponent ( string name , Type type )
@@ -144,10 +155,10 @@ public override void RegisterComponent(string name, Type contractType, Type type
144155 switch ( lifestyle )
145156 {
146157 case ComponentLifeStyleType . Transient :
147- builder = new TransientComponentBuilder ( name , type ) ;
158+ builder = new TransientComponentBuilder ( this . serviceProvider , name , type ) ;
148159 break ;
149160 case ComponentLifeStyleType . Singleton :
150- builder = new SingletonComponentBuilder ( name , type ) ;
161+ builder = new SingletonComponentBuilder ( this . serviceProvider , name , type ) ;
151162 break ;
152163 }
153164
0 commit comments