Forked from grumpydev/TestRenderContextFactory.cs
Last active
December 10, 2015 21:18
-
-
Save jchannon/4494412 to your computer and use it in GitHub Desktop.
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
protected override NancyInternalConfiguration InternalConfiguration | |
{ | |
get | |
{ | |
return | |
NancyInternalConfiguration.WithOverrides(x => x.RenderContextFactory = typeof (TestRenderContextFactory)); | |
} | |
} |
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