コード例 #1
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);
            }
        }