Created
August 8, 2016 15:09
-
-
Save stefc/b29a977b24f161bd7ca0b29666215add to your computer and use it in GitHub Desktop.
Bootstrapper for NancyFx combined with a FeatureToggle (FeatureSwitcher)
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
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