Пример #1
0
        public DefaultRegistry()
        {
            Scan(
                scan => {
                scan.TheCallingAssembly();
                scan.WithDefaultConventions();
                scan.With(new ControllerConvention());
            });
            //For<IExample>().Use<Example>();

            For <IFeatureContextProvider>().Use <OwinFeatureContextProvider>().Singleton();
            For <IFeatureStore>().Use(new ZooKeeperFeatureStore("localhost:2181/TestWebApp")).Singleton();
            For <IFeatures>().Use <Features>().Singleton();
            For(typeof(IMyFeatures)).Use(FeatureFlagAccessor.Build <IMyFeatures>()).Singleton();
        }
Пример #2
0
        public void BuildAccessor()
        {
            var n = new NameValueCollection();

            n.Add("features.featureA", "true");
            n.Add("features.FeatureB", "true");


            var t = FeatureFlagAccessor.BuildAndInstanciate <IMyFeatures>(
                new Features(new CachingFeatureStore(new AppSettingsFeatureStore("features.", n, true)),
                             new AmbiantContextProvider()));

            Assert.True(t.FeatureA);

            Assert.True(t.FeatureB);

            Assert.False(t.FeatureC);
        }
Пример #3
0
        public void Setup()
        {
            var n = new NameValueCollection();

            n.Add("features.FeatureA", "true");
            n.Add("features.FeatureC", @"
{
    'rules': [
        {
            'rule': 'Schedule',
            'from': '2016-11-28T12:00:00',
            'to': '2016-11-28T14:00:00'
        }
    ]
}"
                  );

            ambiantContextProvider = new AmbiantContextProvider();
            Features.Setup(new CachingFeatureStore(new AppSettingsFeatureStore("features.", n, true)), ambiantContextProvider);;

            SomeFeatures = FeatureFlagAccessor.BuildAndInstanciate <ISomeFeatures>(Features.Current);
        }
Пример #4
0
 public static FeatureFlagsConfig AddAccessor <T>(this FeatureFlagsConfig config) where T : class
 {
     config.AdditionnalAccessors.Add(typeof(T), FeatureFlagAccessor.Build <T>());
     return(config);
 }