Created
December 3, 2013 12:56
-
-
Save thecodejunkie/7768714 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
namespace NancyEmbeddedTest | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using Nancy; | |
using Nancy.Bootstrapper; | |
using Nancy.ViewEngines; | |
public class Modules : NancyModule | |
{ | |
public Modules() | |
{ | |
Get["/"] = parameters => { | |
return "Hi"; | |
}; | |
} | |
} | |
public class MyBootstrapper : DefaultNancyBootstrapper | |
{ | |
protected override NancyInternalConfiguration InternalConfiguration | |
{ | |
get | |
{ | |
return NancyInternalConfiguration.WithOverrides(with => | |
{ | |
with.ViewLocationProvider = typeof (MyViewLocationProvider); | |
with.ResourceAssemblyProvider = typeof (MyResourceAssemblyProvider); | |
}); | |
} | |
} | |
} | |
public class MyViewLocationProvider : IViewLocationProvider | |
{ | |
private IResourceReader resourceReader; | |
private IResourceAssemblyProvider resourceAssemblyProvider; | |
public MyViewLocationProvider() | |
: this(new DefaultResourceReader(), new ResourceAssemblyProvider()) | |
{ | |
} | |
/// <summary> | |
/// Initializes a new instance of the <see cref="ResourceViewLocationProvider"/> class. | |
/// </summary> | |
/// <param name="resourceReader">An <see cref="IResourceReader"/> instance that should be used when extracting embedded views.</param> | |
/// <param name="resourceAssemblyProvider">An <see cref="IResourceAssemblyProvider"/> instance that should be used to determine which assemblies to scan for embedded views.</param> | |
public MyViewLocationProvider(IResourceReader resourceReader, IResourceAssemblyProvider resourceAssemblyProvider) | |
{ | |
this.resourceReader = resourceReader; // This is ResouceAssemblyProvider (as passed from the default ctor) and not MyResourceAssemblyProvider | |
this.resourceAssemblyProvider = resourceAssemblyProvider; | |
} | |
public IEnumerable<ViewLocationResult> GetLocatedViews(IEnumerable<string> supportedViewExtensions) | |
{ | |
throw new NotImplementedException(); | |
} | |
public IEnumerable<ViewLocationResult> GetLocatedViews(IEnumerable<string> supportedViewExtensions, string location, string viewName) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
public class MyResourceAssemblyProvider : IResourceAssemblyProvider | |
{ | |
public IEnumerable<Assembly> GetAssembliesToScan() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment