Trains.NET
Trains.NET copied to clipboard
Scoped services
It would be awesome if at the start of every frame, instead of taking a snapshot of IPixelMapper, and tell IImageCache to suspend stuff, we could instead have something like:
- Call DI.ServiceLocator.BeginScope() in a using
- The DI calls Clone() or every service that is needed
- A scope with cloned services is returned from BeginScope()
- The renderer instances etc. all come from that scope
- At the end of the frame the scope is disposed
- When the scope is disposed, it tells the services, so they can pass state to their parent implementations as necessary (ie, IImageCache)