public static void Main(string[] args)
        {
            try
            {
                IDictionary <string, Merchant> merchants = new Dictionary <string, Merchant>();
                DependencyInjector.Assign(typeof(ILogger), typeof(Logger));
                DependencyInjector.Assign(typeof(IMerchantsProcessor), typeof(MerchantsProcessor));
                DependencyInjector.Assign(typeof(ITransactionsProcessor), typeof(TransactionsProcessor));
                DependencyInjector.Assign(typeof(IConsoleHelper), typeof(ConsoleHelper));
                DependencyInjector.Assign(typeof(IFileHelper), typeof(FileHelper));

                logger = (ILogger)DependencyInjector.CreateInstance(typeof(ILogger));
                var merchantFile      = "merchants.txt";
                var transactionstFile = "transactions.txt";

                var transactionsProcessor = (ITransactionsProcessor)DependencyInjector.CreateInstance(typeof(ITransactionsProcessor));
                transactionsProcessor.FileHelperProperty    = (IFileHelper)DependencyInjector.CreateInstance(typeof(IFileHelper));
                transactionsProcessor.ConsoleHelperProperty = (IConsoleHelper)DependencyInjector.CreateInstance(typeof(IConsoleHelper));
                var merchantProcessor = (IMerchantsProcessor)DependencyInjector.CreateInstance(typeof(IMerchantsProcessor));
                merchantProcessor.FileHelperProperty    = (IFileHelper)DependencyInjector.CreateInstance(typeof(IFileHelper));
                merchantProcessor.ConsoleHelperProperty = (IConsoleHelper)DependencyInjector.CreateInstance(typeof(IConsoleHelper));
                merchants = merchantProcessor.ReadMerchants(merchantFile);
                transactionsProcessor.ReadTransactions(transactionstFile, merchants);
                Console.ReadLine();
            }
            catch (Exception exc)
            {
                var logger = (ILogger)DependencyInjector.CreateInstance(typeof(ILogger));
                logger.WriteError(exc.ToString());
                Console.WriteLine("Error while processing fees");
            }
        }
        public IDictionary <string, Merchant> ReadMerchants(string merchantFile)
        {
            DependencyInjector.Assign(typeof(ITransactionParser), typeof(TransactionParser));
            DependencyInjector.Assign(typeof(IMerchantParser), typeof(MerchantParser));
            DependencyInjector.Assign(typeof(IFeeCalculator), typeof(FeeCalculator));
            DependencyInjector.Assign(typeof(IProcessedTransactionWriter), typeof(ProcessedTransactionWriter));
            DependencyInjector.Assign(typeof(IMerchantReader), typeof(MerchantReader));
            DependencyInjector.Assign(typeof(ITransactionFileReader), typeof(TransactionFileReader));
            DependencyInjector.Assign(typeof(ILogger), typeof(Logger));

            var logger = (ILogger)DependencyInjector.CreateInstance(typeof(ILogger));
            IDictionary <string, Merchant> merchants = new Dictionary <string, Merchant>();

            if (!string.IsNullOrEmpty(merchantFile))
            {
                try
                {
                    if (FileHelperProperty.FileExists(merchantFile))
                    {
                        var merchantParser =
                            (IMerchantParser)DependencyInjector.CreateInstance(typeof(IMerchantParser));
                        var merchantReader =
                            (IMerchantReader)DependencyInjector.CreateInstance(typeof(IMerchantReader));

                        var file = FileHelperProperty.OpenFile(merchantFile);
                        merchants = merchantReader.Read(file, merchantParser);
                        FileHelperProperty.CloseFile(file);
                    }
                    else
                    {
                        ConsoleHelperProperty.WriteLine("No merchant file");
                    }
                }
                catch (Exception exception)
                {
                    string message = $"Error while processing fees: {exception.Message}";
                    logger.WriteError(message);
                    ConsoleHelperProperty.WriteLine("Error while processing merchant data");
                }
            }

            return(merchants);
        }
        public void ReadTransactions(string transactionstFile, IDictionary <string, Merchant> merchants)
        {
            DependencyInjector.Assign(typeof(ITransactionParser), typeof(TransactionParser));
            DependencyInjector.Assign(typeof(IMerchantParser), typeof(MerchantParser));
            DependencyInjector.Assign(typeof(IFeeCalculator), typeof(FeeCalculator));
            DependencyInjector.Assign(typeof(IProcessedTransactionWriter), typeof(ProcessedTransactionWriter));
            DependencyInjector.Assign(typeof(IMerchantReader), typeof(MerchantReader));
            DependencyInjector.Assign(typeof(ITransactionFileReader), typeof(TransactionFileReader));
            DependencyInjector.Assign(typeof(ILogger), typeof(Logger));

            var logger = (ILogger)DependencyInjector.CreateInstance(typeof(ILogger));

            try
            {
                if (!string.IsNullOrEmpty(transactionstFile))
                {
                    if (FileHelperProperty.FileExists(transactionstFile))
                    {
                        var calculator        = (IFeeCalculator)DependencyInjector.CreateInstance(typeof(IFeeCalculator));
                        var transactionParser =
                            (ITransactionParser)DependencyInjector.CreateInstance(typeof(ITransactionParser));
                        var processedTransactionWriter =
                            (IProcessedTransactionWriter)DependencyInjector.CreateInstance(
                                typeof(IProcessedTransactionWriter));
                        var transactionReader =
                            (ITransactionFileReader)DependencyInjector.CreateInstance(typeof(ITransactionFileReader));

                        var         file        = FileHelperProperty.OpenFile(transactionstFile);
                        var         monthNumber = 0;
                        Transaction transaction;
                        calculator.InitializeFeeCalculation();

                        while ((transaction = transactionReader.ReadSingleEntry(file, merchants, transactionParser)) != null)
                        {
                            if (transaction.Owner != null)
                            {
                                var processedTransaction = calculator.CalculateFee(transaction);

                                if (monthNumber != 0 &&
                                    monthNumber != processedTransaction.RelatedTransaction.DoneOn.Month)
                                {
                                    ConsoleHelperProperty.WriteLine("\n");
                                }

                                var stringifiedTransaction =
                                    processedTransactionWriter.ConvertTransactionToTextEntry(processedTransaction);
                                ConsoleHelperProperty.WriteLine(stringifiedTransaction);
                                monthNumber = processedTransaction.RelatedTransaction.DoneOn.Month;
                            }
                        }
                        FileHelperProperty.CloseFile(file);
                    }
                    else
                    {
                        ConsoleHelperProperty.WriteLine("No transaction file");
                        throw new ArgumentException("Transaction file does not exist");
                    }
                }
            }
            catch (Exception exception)
            {
                string message = $"Error while processing fees: {exception.Message}";
                logger.WriteError(message);
                ConsoleHelperProperty.WriteLine("Error while processing tramsaction data");
            }
        }