Skip to content

Commit 9d2aa47

Browse files
author
maximv
committed
adding the docs for the #142
1 parent cbcd672 commit 9d2aa47

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/DryIoc.Docs/FaqAutofacMigration.md

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Owned instances](#owned-instances)
1212
- [Using constructor with most resolvable parameters](#using-constructor-with-most-resolvable-parameters)
1313
- [Modules](#modules)
14+
- [IRegistrationSource and the dynamic registrations](#iregistrationsource-and-the-dynamic-registrations)
1415

1516

1617
## Autofac version
@@ -343,3 +344,20 @@ And here the equivalent in DryIoc without use of any additional abstractions exc
343344
var a = container.Resolve<A>();
344345
Assert.IsInstanceOf<B>(a.B);
345346
```
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+
```

0 commit comments

Comments
 (0)