Exemplo n.º 1
0
 public MoveHorizontallyOnInput(
     Collider Parent
     , InputRepository Inputs)
 {
     this.Parent = Parent;
     this.Inputs = Inputs;
 }
        public void Execute()
        {
            try
            {
                //init object
                IRepository _InputRepository = new InputRepository();

                if (_InputRepository.HasFiles())
                {
                    OutputRepository _outputRepository = new OutputRepository();

                    //Get files from path
                    FileInfo[] files = _InputRepository.GetAll();

                    //Extract information by each one
                    Parallel.ForEach(files, item =>
                    {
                        OutputFileContent outputFileContent = null;

                        try
                        {
                            //try parse files
                            outputFileContent = AnalyzeFile(item);
                        }
                        catch (Exception ex)
                        {
                            //Move to rejected folder if has error to parse
                            _InputRepository.RejectFile(item);
                            _logger.Error(ex, $"The file {item.Name} cannot be converted and has been moved to the rejected folder.");

                            //move to next interaction
                            return;
                        }

                        //log the processed information
                        _logger.Information($"Processed file {item.FullName} output: {Serializer.Serialize(outputFileContent)}");

                        //Save file in output diretory
                        _outputRepository.AddFile(outputFileContent);
                        //create backup
                        _InputRepository.BackupFile(item.FullName);
                        //delete from input folder
                        _InputRepository.DeleteFile(item.FullName);
                    });
                }
            }
            catch (IOException ex)
            {
                _logger.Error(ex, "An I/O error is ocurred");
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "An error is ocurred");
            }
        }
        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);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Assembly assembly = Assembly.GetEntryAssembly() ?? throw new NullReferenceException();

            IEnumerable <ISolution> solutions = assembly.GetTypes()
                                                .Where(t => t.GetTypeInfo().IsClass&& typeof(ISolution).IsAssignableFrom(t))
                                                .OrderBy(t => t.FullName)
                                                .Select(t => Activator.CreateInstance(t) as ISolution)
                                                .OfType <ISolution>();

            {
                IInputRepository inputRepository = new InputRepository();
                foreach (ISolution solution in solutions)
                {
                    IEnumerable <Result> results = solution.GetResults(inputRepository);
                    Console.WriteLine($"Solution to ''{solution.Name}'' is: {string.Join(", ", results.Select(r => r.ToString()))}");
                }
            }

            Console.ReadKey();
        }
Exemplo n.º 5
0
 public CytelController(IConfiguration configuration)
 {
     customerRepository = new InputRepository(configuration);
 }
Exemplo n.º 6
0
        public Player(
            InputRepository Inputs,
            World world,
            //Remove this
            IGame Game1)
        {
            this.Inputs    = Inputs;
            Width          = 700;
            Height         = 1000;
            this.Game1     = Game1;
            BodyAnimation  = CreateBodyAnimator();
            HeadAnimation  = CreateHeadAnimator();
            HandsAnimation = CreateHandsAnimator();

            Right_ChestPaperDetetor = new Detector <IPlayerMovementBlocker>(1150, -500, 200, 200)
            {
                Parent = this
            };
            Right_FeetPaperDetector = new Detector <IPlayerMovementBlocker>(1150, 500, 200, 200)
            {
                Parent = this
            };
            world.Add(Right_ChestPaperDetetor);
            world.Add(Right_FeetPaperDetector);

            Left_ChestPaperDetetor = new Detector <IPlayerMovementBlocker>(-600, -500, 200, 200)
            {
                Parent = this
            };
            Left_FeetPaperDetector = new Detector <IPlayerMovementBlocker>(-600, 500, 200, 200)
            {
                Parent = this
            };
            world.Add(Left_ChestPaperDetetor);
            world.Add(Left_FeetPaperDetector);

            DeathDetector = new Detector <IPlayerMovementBlocker>(-300, 500, 100, 100)
            {
                Parent = this
            };
            world.Add(DeathDetector);

            GroundDetector = new Detector <IPlayerMovementBlocker>(100, 1250, 500, 250)
            {
                Parent = this
            };
            world.Add(GroundDetector);

            UpdateHandler = new UpdateGroup(
                new MoveHorizontallyOnInput(this, Inputs)
                , new SetPlayerDirection(this)
                , new AffectedByGravity(this)
                , new PlayersJump(this, Inputs, AudiosToPlay.Add)
                , new GrabPaperNearPlayersFeetAsFirstOption_Right(this)
                , new GrabPaperNearPlayersFeetAsFirstOption_Left(this)
                , new GrabPaperThatThePlayerIsStandingOn(this)
                , new GrabPaperNearPlayersChest_Right(this)
                , new GrabPaperNearPlayersChest_Left(this)
                , new GrabPaperNearPlayersFeetAsLastOption_Right(this)
                , new GrabPaperNearPlayersFeetAsLastOption_Left(this)
                , new SpecialDownDropPaper(this)
                , new DropPaper_Right(this)
                , new DropPaper_Left(this)
                , new LimitSpeed(this, 80, 150)
                );

            CollisionHandler = new CollisionHandlerGroup(
                new StopsWhenBotCollidingWith <IPlayerMovementBlocker>(this)
                , new StopsWhenTopCollidingWith <Block>(this)
                , new HandlePaperFallingInThehead(this, Game1, AudiosToPlay.Add)
                , new StopsWhenLeftCollidingWith <IPlayerMovementBlocker>(this)
                , new StopsWhenRightCollidingWith <IPlayerMovementBlocker>(this)
                );
            world.Add(this);
        }
Exemplo n.º 7
0
 public PlayersJump(Player Player, InputRepository Input, Action <string> PlayAudio)
 {
     this.Player    = Player;
     this.Input     = Input;
     this.PlayAudio = PlayAudio;
 }