static void Main(string[] args) { // factory pattern using Interface var result = FeatFactory .GetFeatureImplementation(Constants.FeatFlag) .DoStuff(); Console.WriteLine(result); // factory using Func<> var features = FeatureFunctions <Func <string, int, string> > .Create(new NewFeature().ProcessSomeData, new NewFeature().ProcessSomeDataV2); result = FeatFactory.FuncFactory(features, Constants.FeatFlag == "mycoolFlag")("foo", 1); Console.WriteLine(result); }
/// <summary> /// Takes FeatureFunction wrapper which has the new and old method we are wanting to switch on /// as well as boolean value on whether to use the new feature or not /// </summary> /// <param name="features"></param> /// <param name="flagOn"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T FuncFactory <T>(FeatureFunctions <T> features, bool flagOn) { return(!flagOn ? features.FeatOld : features.FeatNew); }