示例#1
0
        public static void ShowHowCORIsWorking()
        {
            #region ChainOfResponsibility(COR)

            IHandlerFactory _factory = new HandlerFactory();


            var awesomeRequest = new AwesomeHttpRequest
            {
                IsAwesome       = true,
                Name            = "",
                RobotsDestroyed = 0
            };

            var validationHandler = _factory.Get(HandlerTypes.Validation);
            var coolnessHandler   = _factory.Get(HandlerTypes.Coolness);
            var dbHandler         = _factory.Get(HandlerTypes.DataBase);

            validationHandler.SetNextHandler(coolnessHandler);
            coolnessHandler.SetNextHandler(dbHandler);

            var handlingResults = validationHandler.Handle(awesomeRequest);

            #endregion ChainOfResponsibility(COR)
        }
        protected void InitHandlers()
        {
            handlers = new Dictionary <MessageType, AbstractMessageHandler>();
            handlers.Add(MessageType.Solid, HandlerFactory <SolidHandler> .Get());
            handlers.Add(MessageType.Electro, HandlerFactory <ElectroHandler> .Get());
            handlers.Add(MessageType.SliderEnd, HandlerFactory <SliderEndHandler> .Get());
            handlers.Add(MessageType.Bump, HandlerFactory <BumpHandler> .Get());
            handlers.Add(MessageType.Hole, HandlerFactory <HoleHandler> .Get());
            handlers.Add(MessageType.DetentSlider, HandlerFactory <DetentHandler> .Get());
            handlers.Add(MessageType.Tracking, HandlerFactory <TrackingHandler> .Get());
            // Todo Change to real handler
            handlers.Add(MessageType.ButtonContact, HandlerFactory <ButtonHandler> .Get());
            handlers.Add(MessageType.ButtonUpdate, HandlerFactory <ButtonHandler> .Get());
            handlers.Add(MessageType.DetentDial, HandlerFactory <DialDetentHandler> .Get());

            // Pilot Stuff
            handlers.Add(MessageType.GridButtonCodeContact, HandlerFactory <GridButtonCodeHandler> .Get());
            handlers.Add(MessageType.GridButtonCodeUpdate, HandlerFactory <GridButtonCodeHandler> .Get());
            handlers.Add(MessageType.GridButtonContact, HandlerFactory <GridButtonHandler> .Get());
            handlers.Add(MessageType.GridButtonUpdate, HandlerFactory <GridButtonHandler> .Get());

            // Catapult
            handlers.Add(MessageType.CatapultArm, HandlerFactory <CatapultHandler> .Get());

            // Box
            handlers.Add(MessageType.BoxTouching, HandlerFactory <BoxHandler> .Get());

            // Marble
            handlers.Add(MessageType.MarbleImpact, HandlerFactory <MarbleHandler> .Get());

            // Walkthrough
            handlers.Add(MessageType.WalkthroughDial, HandlerFactory <WalkthroughHandler> .Get());
        }
示例#3
0
    protected void InitHandlers()
    {
        handlers = new Dictionary <MessageType, AbstractMessageHandler>();
        // Todo Change to real handler
        // Room 1
        handlers.Add(MessageType.ElectroProjectile, HandlerFactory <ElectroProjectileHandler> .Get());
        handlers.Add(MessageType.ElectroWall, HandlerFactory <ElectroWallHandler> .Get());
        handlers.Add(MessageType.ButtonUpdate, HandlerFactory <ButtonHandler> .Get());

        // Room 2
        handlers.Add(MessageType.SolidWall, HandlerFactory <SolidWallHandler> .Get());
        handlers.Add(MessageType.RockerButton, HandlerFactory <RockerHandler> .Get());
        handlers.Add(MessageType.Slider, HandlerFactory <SliderHandler> .Get());
        handlers.Add(MessageType.Water, HandlerFactory <WaterHandler> .Get());
        handlers.Add(MessageType.SolidObject, HandlerFactory <SolidObjectHandler> .Get());

        //Room 3
        handlers.Add(MessageType.Cube, HandlerFactory <CubeHandler> .Get());
        handlers.Add(MessageType.CubeGrab, HandlerFactory <CubeHandler> .Get());
        handlers.Add(MessageType.PunchCube, HandlerFactory <PunchCubeHandler> .Get());
    }