@@ -106,6 +106,7 @@ public object ResolveKeyed(object? key, Type type)
106
106
107
107
if ( type . IsDelegate ( ) )
108
108
{
109
+ if ( ctxImpl . VerifySingletons ) return ( _ , _ ) => null ;
109
110
if ( IContainer . FactoryRegistry . TryGetValue ( type . TypeHandle . Value , out var factory ) )
110
111
{
111
112
return factory ( this , ctx ) ;
@@ -117,6 +118,7 @@ public object ResolveKeyed(object? key, Type type)
117
118
var genericTypeDefinition = type . GetGenericTypeDefinition ( ) ;
118
119
if ( genericTypeDefinition == typeof ( Func < > ) )
119
120
{
121
+ if ( ctxImpl . VerifySingletons ) return ( _ , _ ) => null ;
120
122
var nestedType = type . GetGenericArguments ( ) [ 0 ] ;
121
123
var nestedFactory = CreateFactory ( ctx , nestedType , key ) ;
122
124
if ( nestedFactory == null ) return null ;
@@ -131,6 +133,7 @@ public object ResolveKeyed(object? key, Type type)
131
133
132
134
if ( genericTypeDefinition == typeof ( Func < , > ) )
133
135
{
136
+ if ( ctxImpl . VerifySingletons ) return ( _ , _ ) => null ;
134
137
var genericArguments = type . GetGenericArguments ( ) ;
135
138
var nestedType = genericArguments [ 1 ] ;
136
139
if ( genericArguments [ 0 ] == typeof ( IContainer ) )
@@ -313,6 +316,7 @@ public object ResolveKeyed(object? key, Type type)
313
316
{
314
317
if ( cReg . Lifetime == Lifetime . Singleton && cReg . SingletonId != uint . MaxValue )
315
318
{
319
+ if ( ctxImpl . VerifySingletons ) return ( _ , _ ) => null ;
316
320
var singletonInstance = Volatile . Read ( ref Singletons [ cReg . SingletonId ] ) ;
317
321
// If Singleton is just being created return waiting factory
318
322
if ( singletonInstance is SingletonLocker )
0 commit comments