ServiceStack uses a dialect of Funq (no support for metadata), where Kephas uses one of MEF/Autofac (requires metadata support). My question has two parts:
How to make ServiceStack and Kephas use one DI container, if this is possible?
Depending on the answer above: how to make ServiceStack services (like
IClientCache) available to Kephas components, knowing that such services may not be annotated with[AppServiceContract]?
You can make ASP.NET and Kephas use one container by choosing to work with Autofac. However, as @mythz pointed out, you will need to provide the
AutofacIoC Adapter to theServiceStack. I don't think you will have any problems with ASP.NET in doing so, asAutofacis the first recommendation of the ASP.NET Core team.For ASP.NET Core, reference the
Kephas.AspNetCorepackage and inherit from the StartupBase class if you need to be all setup. However, if you need to be in control, have a look at https://github.com/kephas-software/kephas/blob/master/src/Kephas.AspNetCore/StartupBase.cs and write your own Startup class. Another resource that you might find useful is theKephas.ServiceStackintegration package.Then, additionally to annotating service contracts and service implementations, Kephas allows you to provide service definitions by implementing the
IAppServiceInfoProviderinterface. These classes are automatically discovered, so this is pretty much everything you have to do.Note in the above example that for
IUserAuthRepositorythere is no implementation provided. This indicates Kephas to auto-discover the implementation in the types registered for composition. Alternatively, feel free to use an instance or a factory in the registration, if you need to be deterministic.