Skip to main content

Practice · 2 of 3

Build the Tiny Container

CHALLENGE
Difficulty: intermediate+25 XP

Implement the Container from the lesson: Register<TService>(Func<TService>) for transient, RegisterSingleton<TService>(Func<TService>) for lazy once-only, Resolve<TService>() throwing InvalidOperationException for unregistered types. ``csharp public sealed class Container { public void Register<TService>(Func<TService> factory); public void RegisterSingleton<TService>(Func<TService> factory); public TService Resolve<TService>(); } ``

Back to lesson: Practice: DI Practice: Fakes, Lifetimes, Wiring