Exemplo n.º 1
0
        public CultureUtil(ICustomILogger customILogger)
        {
            _customILogger = customILogger;

            DateTimeFormatInfo currentDateTimeFormat = Thread.CurrentThread.CurrentCulture.DateTimeFormat;

            DateSeparator    = currentDateTimeFormat.DateSeparator;
            ShortDatePattern = currentDateTimeFormat.ShortDatePattern;

            _customILogger.Debug(string.Format("ShortDatePattern: {0}, DateSeparator: {1}", ShortDatePattern, DateSeparator));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var container = ContainerConfig.Configure();

            using (var scope = container.BeginLifetimeScope())
            {
                ICustomILogger logger = scope.Resolve <ICustomILogger>();

                logger.Debug(string.Format("Start processing with args: {0}", string.Join(", ", args)));

                try
                {
                    ArgsCounterValidation argsCounterValidator = new ArgsCounterValidation(args);

                    if (argsCounterValidator.IsValid)
                    {
                        IDateParserUtil dateParserUtil = scope.Resolve <IDateParserUtil>();

                        DateTime?startDate = dateParserUtil.ParseDate(args[0]);
                        DateTime?endDate   = dateParserUtil.ParseDate(args[1]);

                        if (startDate != null && endDate != null)
                        {
                            IDateRangeParser dateRangeParser = scope.Resolve <IDateRangeParser>();
                            string           range           = dateRangeParser.CalculateRange(startDate.Value, endDate.Value);
                            if (range != null)
                            {
                                logger.Info(range);
                            }
                        }
                    }
                    else
                    {
                        logger.Error(argsCounterValidator.Message);
                    }
                }
                catch (Exception e)
                {
                    logger.Fatal(string.Format("Unknown exception: {0}", e.ToString()));
                }
            }
        }
Exemplo n.º 3
0
 public DateParserUtil(ICustomILogger customLogger)
 {
     _customLogger = customLogger;
 }
Exemplo n.º 4
0
 public DateRangeParser(ICustomILogger customILogger, IPatternsUtil patternsUtil)
 {
     _customILogger = customILogger;
     _patternsUtil  = patternsUtil;
 }