Autofac and ReactiveUI 6

less than 1 minute read

Today, I updated my previous helper class that replaced the standard RxUI service locator with Autofac container. ReactiveUI 6 introduced some breaking changes and I had to update the code to make it work.

Basically, RxApp has no method to register a custom resolver. Instead, it always uses the ModernDependencyResolver locator from Splat. However, this locator can work with any other type of resolver that implements IMutableDependencyResolver interface. There is one new member in this interface, ServiceRegistrationCallback, which is used nowhere in RxUI6 so I didn’t bother implementing it.

 I also refactored Jason Nuget’s routing sample to use this locator as an example. The full code can be found on GitHub. It also shows a boilerplate for routed views with RxUI, which is quite handy for anyone starting to mock around with the framework.
The IViewFor interface resolves the ViewModel property dependencies, so I did nothing to implement the DependencyProperty implementation with Autofac, although such examples exist. I feel that if you choose to use IViewFor-style bindings (which is recommended), you won’t need this anyway.