Example #1
0
        public T Create <T>(object obj)
        {
            IFactoryMethod <T> method = this as IFactoryMethod <T>;

            if (method != null)
            {
                return(method.Create(obj));
            }

            throw new NotImplementedException(String.Format("Factory method for type {0} not implemented.", typeof(T).ToString()));
        }
Example #2
0
        static Program()
        {
            _logger = new ConsoleLogger();

            // TODO: create via injection library
            _factory      = new SomeObjectFactory(_logger);
            _otherFactory = new SomeOtherObjectFactory(_logger);

            _factoryMethod      = new SomeFactoryMethod(_logger);
            _otherFactoryMethod = new SomeOtherFactoryMethod(_logger);

            IAddSubtract <int> addSubtract = new AdditionSubtraction();

            _multiplyDivideAdapter = new MultiplyDivideAdapter(addSubtract);

            _hotWaterPipeBridge  = new WaterPipeBridge(new HotWaterPipeImp(_logger), _logger);
            _coldWaterPipeBridge = new WaterPipeBridge(new HotWaterPipeImp(_logger), _logger);

            _composite = _MakeCompositeTree();

            _wrapper = new WrappingPaper(new GiftBox(new Gift("Teddy bear")));

            _facade = new Facade(new FacadeChildA(), new FacadeChildB(), new FacadeChildC());
        }
 public FastPersonFactoryMethodExample(
     IFactoryMethod<FastPerson> factoryMethod)
 {
     _factoryMethod = factoryMethod;
 }
 public FastPersonFactoryMethodExample(
     IFactoryMethod <FastPerson> factoryMethod)
 {
     _factoryMethod = factoryMethod;
 }
 public NormalPersonFactoryMethodExample(
     IFactoryMethod <NormalPerson> factoryMethod)
 {
     _factoryMethod = factoryMethod;
 }