Skip to content

Instantly share code, notes, and snippets.

@stefc
Created August 8, 2016 15:09
Show Gist options
  • Save stefc/b29a977b24f161bd7ca0b29666215add to your computer and use it in GitHub Desktop.
Save stefc/b29a977b24f161bd7ca0b29666215add to your computer and use it in GitHub Desktop.
Bootstrapper for NancyFx combined with a FeatureToggle (FeatureSwitcher)
using System.Collections.Generic;
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
using FeatureSwitcher;
using txs.nextgen.apigateway.todo;
namespace txs.nextgen.apigateway
{
// Bootstrapper for NancyFx that check FeatureToggle ("FeatureSwitcher") for loading NancyFx
public class Bootstrapper : DefaultNancyBootstrapper
{
protected override IEnumerable<ModuleRegistration> Modules
{
get
{
return base.Modules.Where(Check<ToDoModule,ToDoApp>);
}
}
private bool Check<TModule,TFeature>(ModuleRegistration moduleReg) where TModule : INancyModule where TFeature : IFeature
{
return (moduleReg.ModuleType != typeof(TModule)) || (Feature<TFeature>.Is().Enabled);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment