Esempio n. 1
0
 // filles the options (dictonairy) of there respective factories.
 // calles all diferent options to register themselves at there factories
 public static void RegisterStrategies()
 {
     CalculationStrategyFactory.GetInstance().ResetDictionary();
     CalculationStrategyDecoratorFactory.GetInstance().ResetDictionary();
     AND.RegisterStrategy();
     OR.RegisterStrategy();
     NOT.RegisterStrategy();
     NOTDecorator.RegisterStrategy();
 }
Esempio n. 2
0
        public void AddStrategy(string strategyName)
        {
            ICalculationStrategy strategy;

            if (strategyName == "NAND")
            {
                strategy = CalculationStrategyFactory.GetInstance().CreateStrategy("AND");
                strategy = CalculationStrategyDecoratorFactory.GetInstance().CreateStrategy(strategy, "NOTDecorator");
                _node.AddStrategy(strategy);
            }

            else if (strategyName == "NOR")
            {
                strategy = CalculationStrategyFactory.GetInstance().CreateStrategy("OR");
                strategy = CalculationStrategyDecoratorFactory.GetInstance().CreateStrategy(strategy, "NOTDecorator");
                _node.AddStrategy(strategy);
            }

            else
            {
                strategy = CalculationStrategyFactory.GetInstance().CreateStrategy(strategyName);
                _node.AddStrategy(strategy);
            }
        }
Esempio n. 3
0
 public static void RegisterStrategy()
 {
     CalculationStrategyDecoratorFactory.GetInstance().AddNodeType <NOTDecorator>("NOTDecorator");
 }