File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11
11
- [ Owned instances] ( #owned-instances )
12
12
- [ Using constructor with most resolvable parameters] ( #using-constructor-with-most-resolvable-parameters )
13
13
- [ Modules] ( #modules )
14
+ - [ IRegistrationSource and the dynamic registrations] ( #iregistrationsource-and-the-dynamic-registrations )
14
15
15
16
16
17
## Autofac version
@@ -343,3 +344,20 @@ And here the equivalent in DryIoc without use of any additional abstractions exc
343
344
var a = container .Resolve <A >();
344
345
Assert .IsInstanceOf <B >(a .B );
345
346
```
347
+
348
+ ## IRegistrationSource and the dynamic registrations
349
+
350
+ [ The related case] ( https://github.com/dadhi/DryIoc/issues/143 )
351
+
352
+ Example of the dynamic registration of the types started with the ` Asp ` prefix:
353
+
354
+ ``` cs
355
+ IEnumerable < DynamicRegistration > GetAspTypes (Type serviceType , object serviceKey )
356
+ {
357
+ if (serviceType .Namespace .StartsWith (" ASP" , true , CultureInfo .InvariantCultureIgnoreCase ))
358
+ return new [] { new DynamicRegistration (new ReflectionFactory (serviceType ), IfAlreadyRegistered .Keep ) };
359
+ return null ;
360
+ }
361
+
362
+ container = container .With (rules => rules .WithDynamicRegistrations (GetAspTypes ));
363
+ ```
You can’t perform that action at this time.
0 commit comments