FeatureSwitcher icon indicating copy to clipboard operation
FeatureSwitcher copied to clipboard

Features that enable based on a date

Open DustinKingen opened this issue 8 years ago • 1 comments

Hi Max,

I am wondering what the preferred method is for extending this framework to support Features that are enabled after some DateTime:

For example:

Configure the DateTime when the feature should start.

Features
    .Are
    .ConfiguredBy
    .Custom(featureName => new DateTime(2017, 1, 1));

Check the feature is enabled.

Feature<Sample>.Is().EnabledOn(new DateTime(2017, 1, 2)) // Returns true
Feature<Sample>.Is().EnabledNow() // Returns false when DateTime.Now is before 2017

DustinKingen avatar Sep 28 '16 22:09 DustinKingen

Hi Dustin,

Given you don't need to configure the timestamps to check against, I wouldn't add the additional functionality at the check side, it would still looks like Feature<Sample>.Is().Enabled. You can easily add a behavior function for temporal checks.

If you have to check against different timestamps, I would use FeatureSwitcher.Contexteer and put the timestamp to check against as a property into the IContext instance. You can reuse the same behavior function for temporal checks, parametrized by the timestamp from the context instead of DateTime.Now.

mexx avatar Oct 03 '16 21:10 mexx