File tree Expand file tree Collapse file tree
DNN Platform/Library/ComponentModel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,8 +7,12 @@ namespace DotNetNuke.ComponentModel
77 using System . Collections ;
88 using System . Collections . Generic ;
99
10+ using DotNetNuke . Instrumentation ;
11+
1012 public static class ComponentFactory
1113 {
14+ private static readonly ILog Logger = LoggerSource . Instance . GetLogger ( typeof ( ComponentFactory ) ) ;
15+
1216 public static IContainer Container { get ; set ; }
1317
1418 public static void InstallComponents ( params IComponentInstaller [ ] installers )
@@ -200,6 +204,7 @@ private static void VerifyContainer()
200204 {
201205 if ( Container == null )
202206 {
207+ Logger . Warn ( "Container was null, instantiating SimpleContainer" ) ;
203208 Container = new SimpleContainer ( ) ;
204209 }
205210 }
Original file line number Diff line number Diff line change @@ -6,11 +6,14 @@ namespace DotNetNuke.ComponentModel;
66using System ;
77using System . Collections ;
88
9+ using DotNetNuke . Instrumentation ;
10+
911using Microsoft . Extensions . DependencyInjection ;
1012
1113/// <summary>A container which gets components from an <see cref="IServiceProvider"/> for components not registered.</summary>
1214public class ContainerWithServiceProviderFallback : IContainer
1315{
16+ private static readonly ILog Logger = LoggerSource . Instance . GetLogger ( typeof ( ContainerWithServiceProviderFallback ) ) ;
1417 private readonly IContainer container ;
1518 private readonly IServiceProvider serviceProvider ;
1619
@@ -115,7 +118,18 @@ public object GetComponent(string name)
115118
116119 /// <inheritdoc />
117120 public TContract GetComponent < TContract > ( )
118- => this . container . GetComponent < TContract > ( ) ?? this . serviceProvider . GetService < TContract > ( ) ;
121+ {
122+ Logger . Trace ( $ "Getting component for { typeof ( TContract ) . FullName } ") ;
123+ var service = this . container . GetComponent < TContract > ( ) ;
124+ if ( service is not null )
125+ {
126+ Logger . Trace ( $ "Got component for { typeof ( TContract ) . FullName } from container") ;
127+ return service ;
128+ }
129+
130+ Logger . Trace ( $ "Getting component for { typeof ( TContract ) . FullName } from service provider") ;
131+ return this . serviceProvider . GetService < TContract > ( ) ;
132+ }
119133
120134 /// <inheritdoc />
121135 public TContract GetComponent < TContract > ( string name )
You can’t perform that action at this time.
0 commit comments