示例#1
0
        private ICalculator CreateArithmeticController(IInputRepository inputRepositoryObjectStub, IPrintRepository printRepositoryObjectStub)
        {
            ISeparationEquation  separationEquation  = new ArithmeticSeparationEquation();
            ICalculationEquation calculationEquation = new ArithmeticCalculationEquation();

            ICalculatorRepository calculatorRepository = new CalculatorRepository(separationEquation, calculationEquation);

            CalculatorController calculator = new CalculatorController(inputRepositoryObjectStub, printRepositoryObjectStub, calculatorRepository);

            return(calculator);
        }
        public override ICalculator FactoryMethod()
        {
            //Poor Man's DI
            IValidationEquation  validationRepository = new ArithmeticValidationEquation();
            ISeparationEquation  separationEquation   = new ArithmeticSeparationEquation();
            ICalculationEquation calculationEquation  = new ArithmeticCalculationEquation();

            IInputRepository      inputRepository      = new InputRepository(validationRepository);
            IPrintRepository      printRepository      = new PrintRepository();
            ICalculatorRepository calculatorRepository = new CalculatorRepository(separationEquation, calculationEquation);

            CalculatorController calculator = new CalculatorController(inputRepository, printRepository, calculatorRepository);

            return(calculator);
        }
 public void ClassInitialize()
 {
     arithmeticCalculation = new ArithmeticCalculationEquation();
 }