Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active June 23, 2016 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/e26dab5bd49ca0a5e15005e1b8aef01a to your computer and use it in GitHub Desktop.
Save dcomartin/e26dab5bd49ca0a5e15005e1b8aef01a to your computer and use it in GitHub Desktop.
using MediatR;
using Nancy.Routing;
using Nancy.TinyIoc;
namespace Nancy.Linker.Demo
{
public class MyNancyBootstrapper : DefaultNancyBootstrapper
{
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
container.Register<IResourceLinker>(
(x, overloads) =>
new ResourceLinker(x.Resolve<IRouteCacheProvider>(),
x.Resolve<IRouteSegmentExtractor>(), x.Resolve<IUriFilter>()));
container.Register<IMediator>((x, overloads) => new Mediator(x.Resolve, x.ResolveAll));
container.Register<IAsyncRequestHandler<Features.ChangePricingLevel.Command, Unit>>(
(x, overloads) => new Features.ChangePricingLevel.Handler(() => new FakeDb()));
container.Register<IAsyncRequestHandler<Features.GetCustomer.Query, Features.GetCustomer.ViewModel>>(
(x, overloads) => new Features.GetCustomer.Handler((() => new FakeDb()), x.Resolve<RouteLinker>()));
}
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
base.ConfigureRequestContainer(container, context);
container.Register<RouteLinker>((x, overloads) => new RouteLinker(x.Resolve<IResourceLinker>(), context));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment