public static IStrategyPattern RunStrategy(string writerType) { //if (string.IsNullOrEmpty(strategyType)) // throw new Exception("Application cannot complete"); // if strategyType is not provided, write content to console IStrategyPattern pattern = (IStrategyPattern)readConfigFactory.GetPersitanceObject(writerType); return(pattern); }
public static void Main(string[] args) { IStrategyPattern persistData = Writer_WithStrategy.RunStrategy("CONSOLE"); persistData.WriteUsingStrategy("Hello World!"); //persistData = Writer_WithStrategy.RunStrategy("FILE"); //persistData.WriteUsingStrategy("Hello World!"); Console.ReadKey(); }
public Writer_WithStrategy(IStrategyPattern strategy) { this.strategy = strategy; }
public Context(IStrategyPattern strategy) { this.strategy = strategy; }