Example #1
0
        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);
        }
Example #2
0
        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();
        }
Example #3
0
 public Writer_WithStrategy(IStrategyPattern strategy)
 {
     this.strategy = strategy;
 }
Example #4
0
 public Context(IStrategyPattern strategy)
 {
     this.strategy = strategy;
 }