New answers tagged

1

You might want to check out the code samples repository of the book Dependency Injection Principles, Practices, and Patterns. I co-authored this book. It contains a Pure DI example for an ASP.NET Core web application. This example implements a custom IControllerActivator that acts as Composition Root. This activator implements IDisposable to implement ...


0

After some time I realized the main problem with usage of Singleton pattern for this purpose: it is the inability to replace dependencies with test doubles in tests. It is because the CompositionRoot instance, which implements both IMiddlewareFactory and IControllerActivator, is static. Maybe it would be possible to set specific dependencies in tests using ...


0

Don't try to follow C# DI patterns in Rust. That path will lead you to nothing but pain. Rust is very different from C#, and the sort of patterns that make sense there won't fly in Rust. #[cfg(all(feature = "test", feature = "test2"))] mod Bindings { // stubs for test2 can be binded here pub type Door = crate::Autocar::DoorMod::...


Top 50 recent answers are included