Trains.NET icon indicating copy to clipboard operation
Trains.NET copied to clipboard

Scoped services

Open davidwengier opened this issue 5 years ago • 0 comments

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)

davidwengier avatar Sep 30 '20 06:09 davidwengier