davidwhitney/ReallySimpleFeatureToggle — pull request #2 by davidwhitney (2014-10-15 17:36:03+00:00)
Title: Integrate PR from @rschiefer with fixes.

This PR is based on https://github.com/davidwhitney/ReallySimpleFeatureToggle/pull/1
It implements multi-tenancy in the MVC plugin.

To configure the MVC plugin you must call:

ReallySimpleFeature.Toggles.Configure
.WithPlugin(new WebPlugin(persistRandomPercentageResultToCookie:true))
.WithPlugin(new MvcPlugin());

Now, to lock down the plugin for a specific tenant you can call:

ReallySimpleFeature.Toggles.Configure
.WithPlugin(new WebPlugin(persistRandomPercentageResultToCookie:true))
.WithPlugin(new MvcPlugin(()=>"MyLockedTenant"));

Alternatively, you can provide a method that retrieves the tenant for the current web request (recommended):

ReallySimpleFeature.Toggles.Configure
.WithPlugin(new WebPlugin(persistRandomPercentageResultToCookie:true))
.WithPlugin(new MvcPlugin(()=>SomeMethodCallThatReturnsAString));

Or provide an implementation of the interface:

public interface IRetrieveTheTenantForThisRequest {
string GetCurrentTenant();
}

like:
ReallySimpleFeature.Toggles.Configure
.WithPlugin(new WebPlugin(persistRandomPercentageResultToCookie:true))
.WithPlugin(new MvcPlugin(new MyFactoryThatImplementsIRetrieveTheTenantForThisRequest() ));

All MVC html helpers will then return configurations based on the tenant configured. Omitting this configuration will return the configuration for Tenant.All.