Skip to content

Instantly share code, notes, and snippets.

@davidwhitney
Created December 23, 2010 10:39
Show Gist options
  • Save davidwhitney/752822 to your computer and use it in GitHub Desktop.
Save davidwhitney/752822 to your computer and use it in GitHub Desktop.
Feature set concept
namespace featuerset
{
public class SomeConsumingClass
{
public void RenderEndUserAccountView()
{
var configService = new ServiceThatBringsBackFeatures();
var featureConfig = configService.GetFeatures("RaceForLife");
if(!featureConfig.Features.EndUserAccount.EmailTool.Enabled)
{
// hide email tool
}
if(!featureConfig.Features.EndUserAccount.PageTheming.Enabled)
{
// hide themeing
}
// etc... etc..
}
}
public class ServiceThatBringsBackFeatures
{
public WhiteLabelConfiguration GetFeatures(string whiteLabelName)
{
return FakeLoadByWhiteLabelName(whiteLabelName);
}
private static WhiteLabelConfiguration FakeLoadByWhiteLabelName(string whiteLabelName)
{
var config = new WhiteLabelConfiguration();
return config;
}
}
public class WhiteLabelConfiguration
{
public string WhiteLabelName { get; set; }
public Features Features { get; set; }
public WhiteLabelConfiguration()
{
Features = new Features();
}
}
public class Features
{
public FeatureSet DonationProcess { get; set; }
public FeatureSet PageCreationProcess { get; set; }
public EndUserAccountFeatureSet EndUserAccount { get; set; }
public Features()
{
DonationProcess = new FeatureSet();
PageCreationProcess = new FeatureSet();
EndUserAccount = new EndUserAccountFeatureSet();
}
}
public class FeatureSet: IFeatureSet
{
public bool Enabled { get; set; }
public FeatureSet()
{
Enabled = true;
}
}
public class EndUserAccountFeatureSet: FeatureSet
{
public FeatureSet EmailTool { get; set; }
public FeatureSet PageTheming { get; set; }
public EndUserAccountFeatureSet()
{
Enabled = true;
}
}
public interface IFeatureSet
{
bool Enabled { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment