Last active
December 10, 2015 19:58
-
-
Save grumpydev/4484587 to your computer and use it in GitHub Desktop.
Testing per request view cache implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In ConfigureRequestContainer: | |
#ifdef DEBUG | |
context.Items["DebugViewCache"] = existingContainer.Resolve<IViewCache>(); | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestRenderContextFactory : IRenderContextFactory | |
{ | |
private IViewResolver viewResolver; | |
private IViewCache viewCache; | |
public TestRenderContextFactory(IViewResolver viewResolver, IViewCache viewCache) | |
{ | |
this.viewResolver = viewResolver; | |
this.viewCache = viewCache; | |
} | |
public IRenderContext GetRenderContext(ViewLocationContext viewLocationContext) | |
{ | |
return new DefaultRenderContext( | |
this.viewResolver, | |
viewLocationContext.Context.Items.ContainsKey("DebugViewCache") ? | |
viewLocationContext.Context.Items["DebugViewCache"] as IViewCache : | |
this.viewCache, | |
viewLocationContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment