示例#1
0
 public LinkBuilder(IDateFormatter dateFormatter,
                    IOptions <BusConfig> busOptions, IOptions <RailwayConfig> railwayOptions)
 {
     busConfig          = busOptions.Value;
     railwayConfig      = railwayOptions.Value;
     this.dateFormatter = dateFormatter;
 }
 public BlaBlaCarFinder(IHttpService httpService, IDateFormatter dateFormatter, IOptions <BlaBlaCarConfig> options, IMapsService mapsService)
 {
     this.httpService   = httpService;
     this.dateFormatter = dateFormatter;
     this.mapsService   = mapsService;
     config             = options.Value;
 }
示例#3
0
        public void Setup()
        {
            _trackObjects1 = new List <TrackObject>();
            _trackObjects  = new List <TrackObject>();
            _trackObjects2 = new List <TrackObject>();
            list1          = new List <string> {
                "MAR123", "50000", "50000", "1000", "20151006213456789"
            };
            trackObject           = new TrackObject(list1);
            _receivedTrackObjects = new List <TrackObject>();
            _trackObjects.Add(trackObject);
            _transponderReceiver      = Substitute.For <ITransponderReceiver>();
            _transponderParsing       = Substitute.For <ITransponderParsing>();
            _trackingValidation       = Substitute.For <ITrackingValidation>();
            _dateFormatter            = Substitute.For <IDateFormatter>();
            _trackUpdater             = Substitute.For <ITrackUpdater>();
            _velocityCourseCalculator = Substitute.For <IVelocityCourseCalculator>();
            _separationChecker        = Substitute.For <ISeparationChecker>();
            _print       = Substitute.For <IPrint>();
            _objectifier = Substitute.For <ITrackListEvent>();
            _uut         = new ATMSystem(_objectifier, _trackUpdater, _velocityCourseCalculator, _separationChecker, _print);
            _trackObjectDataEventArgs = new TrackListEventArgs(_trackObjects);

            _objectifier.TrackListReady += (sender, TrackListEventArgs) =>
            {
                _receivedTrackObjects = TrackListEventArgs.TrackObjects;
            };
        }
示例#4
0
        /// <summary>
        /// Initialize the converter options
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="T:log4net.Core.IOptionHandler" /> delayed object
        /// activation scheme. The <see cref="M:log4net.Util.PatternStringConverters.DatePatternConverter.ActivateOptions" /> method must
        /// be called on this object after the configuration properties have
        /// been set. Until <see cref="M:log4net.Util.PatternStringConverters.DatePatternConverter.ActivateOptions" /> is called this
        /// object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then
        /// <see cref="M:log4net.Util.PatternStringConverters.DatePatternConverter.ActivateOptions" /> must be called again.
        /// </para>
        /// </remarks>
        public void ActivateOptions()
        {
            string text = Option;

            if (text == null)
            {
                text = "ISO8601";
            }
            if (SystemInfo.EqualsIgnoringCase(text, "ISO8601"))
            {
                m_dateFormatter = new Iso8601DateFormatter();
            }
            else if (SystemInfo.EqualsIgnoringCase(text, "ABSOLUTE"))
            {
                m_dateFormatter = new AbsoluteTimeDateFormatter();
            }
            else if (SystemInfo.EqualsIgnoringCase(text, "DATE"))
            {
                m_dateFormatter = new DateTimeDateFormatter();
            }
            else
            {
                try
                {
                    m_dateFormatter = new SimpleDateFormatter(text);
                }
                catch (Exception exception)
                {
                    LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + text + "]", exception);
                    m_dateFormatter = new Iso8601DateFormatter();
                }
            }
        }
        public void ActivateOptions()
        {
            string option = this.Option;

            option ??= "ISO8601";
            if (string.Compare(option, "ISO8601", true, CultureInfo.InvariantCulture) == 0)
            {
                this.m_dateFormatter = new Iso8601DateFormatter();
            }
            else if (string.Compare(option, "ABSOLUTE", true, CultureInfo.InvariantCulture) == 0)
            {
                this.m_dateFormatter = new AbsoluteTimeDateFormatter();
            }
            else if (string.Compare(option, "DATE", true, CultureInfo.InvariantCulture) == 0)
            {
                this.m_dateFormatter = new DateTimeDateFormatter();
            }
            else
            {
                try
                {
                    this.m_dateFormatter = new SimpleDateFormatter(option);
                }
                catch (Exception exception)
                {
                    LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + option + "]", exception);
                    this.m_dateFormatter = new Iso8601DateFormatter();
                }
            }
        }
    /// <summary>
    /// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
    /// </summary>
    /// <remarks>
    /// <para>
    /// This is part of the <see cref="IOptionHandler"/> delayed object
    /// activation scheme. The <see cref="ActivateOptions"/> method must 
    /// be called on this object after the configuration properties have
    /// been set. Until <see cref="ActivateOptions"/> is called this
    /// object is in an undefined state and must not be used. 
    /// </para>
    /// <para>
    /// If any of the configuration properties are modified then 
    /// <see cref="ActivateOptions"/> must be called again.
    /// </para>
    /// </remarks>
    public void ActivateOptions() {
      string dateFormatStr = Option;
      if (dateFormatStr == null)
        dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;

      if (
        string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat, true,
                       CultureInfo.InvariantCulture) == 0)
        m_dateFormatter = new Iso8601DateFormatter();
      else if (
        string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat, true,
                       CultureInfo.InvariantCulture) == 0)
        m_dateFormatter = new AbsoluteTimeDateFormatter();
      else if (
        string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat, true,
                       CultureInfo.InvariantCulture) == 0)
        m_dateFormatter = new DateTimeDateFormatter();
      else
        try {
          m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
        } catch (Exception e) {
          LogLog.Error(
            "DatePatternConverter: Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]",
            e);
          m_dateFormatter = new Iso8601DateFormatter();
        }
    }
        /// <summary>
        /// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="IOptionHandler"/> delayed object
        /// activation scheme. The <see cref="ActivateOptions"/> method must
        /// be called on this object after the configuration properties have
        /// been set. Until <see cref="ActivateOptions"/> is called this
        /// object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then
        /// <see cref="ActivateOptions"/> must be called again.
        /// </para>
        /// </remarks>
        public void ActivateOptions()
        {
            string dateFormatStr = Option;

            if (dateFormatStr == null)
            {
                dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
            }

            if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
            {
                m_dateFormatter = new Iso8601DateFormatter();
            }
            else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
            {
                m_dateFormatter = new AbsoluteTimeDateFormatter();
            }
            else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
            {
                m_dateFormatter = new DateTimeDateFormatter();
            }
            else
            {
                try
                {
                    m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
                }
                catch (Exception e)
                {
                    LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]", e);
                    m_dateFormatter = new Iso8601DateFormatter();
                }
            }
        }
示例#8
0
 public CommitDataHeaderRenderer(IHeaderLabelFormatter labelFormatter, IDateFormatter dateFormatter, IHeaderRenderStyleProvider headerRendererStyleProvider, ILinkFactory linkFactory)
 {
     _labelFormatter = labelFormatter;
     _dateFormatter  = dateFormatter;
     _headerRendererStyleProvider = headerRendererStyleProvider;
     _linkFactory = linkFactory;
 }
示例#9
0
        /// <summary>
        /// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="IOptionHandler"/> delayed object
        /// activation scheme. The <see cref="ActivateOptions"/> method must
        /// be called on this object after the configuration properties have
        /// been set. Until <see cref="ActivateOptions"/> is called this
        /// object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then
        /// <see cref="ActivateOptions"/> must be called again.
        /// </para>
        /// </remarks>
        public void ActivateOptions()
        {
            string dateFormatStr = Option;

            if (dateFormatStr == null)
            {
                dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
            }

            if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
            {
                m_dateFormatter = new Iso8601DateFormatter();
            }
            else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat))
            {
                m_dateFormatter = new AbsoluteTimeDateFormatter();
            }
            else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat))
            {
                m_dateFormatter = new DateTimeDateFormatter();
            }
            else
            {
                try
                {
                    m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
                }
                catch (Exception e)
                {
                    LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]", e);
                    m_dateFormatter = new Iso8601DateFormatter();
                }
            }
        }
示例#10
0
 public BusFinder(IHttpService httpService, IDateFormatter dateFormatter, IOptions <BusConfig> options, ILinkBuilder linkBuilder)
 {
     this.httpService   = httpService;
     this.dateFormatter = dateFormatter;
     this.linkBuilder   = linkBuilder;
     config             = options.Value;
     availableStations  = GetAvailableStations().Result;
 }
示例#11
0
        public TimestampedLogFormatter(IDateFormatter dateFormatter)
        {
            if (dateFormatter == null)
            {
                throw new ArgumentNullException("dateFormatter");
            }

            _dateFormatter = dateFormatter;
        }
示例#12
0
 public RailwayFinder(IHttpService httpService, IDateFormatter dateFormatter, IOptions <RailwayConfig> options,
                      IMapsService mapsService, ILinkBuilder linkBuilder)
 {
     this.httpService   = httpService;
     this.dateFormatter = dateFormatter;
     this.mapsService   = mapsService;
     this.linkBuilder   = linkBuilder;
     config             = options.Value;
 }
示例#13
0
        public TimestampedLogFormatter(IDateFormatter dateFormatter)
        {
            if (dateFormatter == null)
            {
                throw new ArgumentNullException("dateFormatter");
            }

            _dateFormatter = dateFormatter;
        }
示例#14
0
 public AlexaSkill(
     SouthBucksBinDayResolver binDayResolver,
     IUserPostcodeRetriever <SkillRequest> userPostcodeRetriever,
     IDateFormatter dateFormatter)
 {
     _binDayResolver        = binDayResolver ?? throw new ArgumentNullException(nameof(binDayResolver));
     _userPostcodeRetriever =
         userPostcodeRetriever ?? throw new ArgumentNullException(nameof(userPostcodeRetriever));
     _dateFormatter = dateFormatter;
 }
 public DefaultDateLocalizationServices(
     IClock clock,
     IWorkContextAccessor workContextAccessor,
     IDateTimeFormatProvider dateTimeFormatProvider,
     IDateFormatter dateFormatter,
     ICalendarManager calendarManager) {
     _clock = clock;
     _workContextAccessor = workContextAccessor;
     _dateTimeFormatProvider = dateTimeFormatProvider;
     _dateFormatter = dateFormatter;
     _calendarManager = calendarManager;
 }
示例#16
0
        public Objectifier(
            ITransponderReceiver receiver,
            ITrackingValidation trackingValidation,
            ITransponderParsing transponderParsing,
            IDateFormatter dateFormatter)
        {
            receiver.TransponderDataReady += MakeTrack;

            _trackingValidation = trackingValidation;
            _transponderParsing = transponderParsing;
            _dateFormatter      = dateFormatter;
        }
示例#17
0
        public void Setup()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _transponderParsing  = new TransponderParsing();
            _trackingValidation  = new TrackingValidation();
            _dateFormatter       = new DateFormatter();
            _uut = new Objectifier(_transponderReceiver, _trackingValidation, _transponderParsing, _dateFormatter);

            _transponderArgsList = new List <string> {
                "ATR423;39045;12932;14000;20151006213456789"
            };
            _transponderDataEventArgs = new RawTransponderDataEventArgs(_transponderArgsList);
        }
示例#18
0
 public DefaultDateLocalizationServices(
     IClock clock,
     IWorkContextAccessor workContextAccessor,
     IDateTimeFormatProvider dateTimeFormatProvider,
     IDateFormatter dateFormatter,
     ICalendarManager calendarManager)
 {
     _clock = clock;
     _workContextAccessor    = workContextAccessor;
     _dateTimeFormatProvider = dateTimeFormatProvider;
     _dateFormatter          = dateFormatter;
     _calendarManager        = calendarManager;
 }
示例#19
0
        //private readonly Lazy<CultureInfo> _cultureInfo;

        public DateTokens(
            IClock clock, 
            IWorkContextAccessor workContextAccessor,
            IDateTimeFormatProvider dateTimeFormats, 
            IDateFormatter dateFormatter,
            IDateLocalizationServices dateLocalizationServices) {
            _clock = clock;
            _workContextAccessor = workContextAccessor;
            _dateTimeFormats = dateTimeFormats;
            _dateFormatter = dateFormatter;
            _dateLocalizationServices = dateLocalizationServices;

            //_cultureInfo = new Lazy<CultureInfo>(() => CultureInfo.GetCultureInfo(_workContextAccessor.GetContext().CurrentCulture));
            
            T = NullLocalizer.Instance;
        }
示例#20
0
        public IDateFormatter Get(Type type)
        {
            IDateFormatter formatter = null;

            if (dateFormatters.TryGetValue(type, out formatter))
            {
                return(formatter);
            }
            else
            {
                // We want to crash if Type is not IDateFormatter
                formatter             = (IDateFormatter)Activator.CreateInstance(type);
                dateFormatters [type] = formatter;
                return(formatter);
            }
        }
示例#21
0
        //private readonly Lazy<CultureInfo> _cultureInfo;

        public DateTokens(
            IClock clock,
            IWorkContextAccessor workContextAccessor,
            IDateTimeFormatProvider dateTimeFormats,
            IDateFormatter dateFormatter,
            IDateLocalizationServices dateLocalizationServices)
        {
            _clock = clock;
            _workContextAccessor      = workContextAccessor;
            _dateTimeFormats          = dateTimeFormats;
            _dateFormatter            = dateFormatter;
            _dateLocalizationServices = dateLocalizationServices;

            //_cultureInfo = new Lazy<CultureInfo>(() => CultureInfo.GetCultureInfo(_workContextAccessor.GetContext().CurrentCulture));

            T = NullLocalizer.Instance;
        }
示例#22
0
        public void Setup()
        {
            _labelFormatter = Substitute.For <IHeaderLabelFormatter>();
            _labelFormatter.FormatLabel(Strings.GetAuthorText(), Arg.Any <int>()).Returns(x => "Author:        ");
            _labelFormatter.FormatLabel(Strings.GetCommitterText(), Arg.Any <int>()).Returns(x => "Committer:     ");
            _labelFormatter.FormatLabel(Strings.GetDateText(), Arg.Any <int>()).Returns(x => "Date:          ");
            _labelFormatter.FormatLabel(Strings.GetAuthorDateText(), Arg.Any <int>()).Returns(x => "Author date:   ");
            _labelFormatter.FormatLabel(Strings.GetCommitDateText(), Arg.Any <int>()).Returns(x => "Commit date:   ");
            _labelFormatter.FormatLabel(Strings.GetCommitHashText(), Arg.Any <int>()).Returns(x => "Commit hash:   ");
            _labelFormatter.FormatLabel(Strings.GetParentsText(), Arg.Any <int>()).Returns(x => "Parent(s):     ");
            _labelFormatter.FormatLabel(Strings.GetChildrenText(), Arg.Any <int>()).Returns(x => "Children:      ");

            _headerRendererStyleProvider = Substitute.For <IHeaderRenderStyleProvider>();
            _linkFactory   = Substitute.For <ILinkFactory>();
            _dateFormatter = Substitute.For <IDateFormatter>();

            _renderer = new CommitDataHeaderRenderer(_labelFormatter, _dateFormatter, _headerRendererStyleProvider, _linkFactory);
        }
示例#23
0
        public void Setup()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();
            _transponderParsing  = Substitute.For <ITransponderParsing>();
            _trackingValidation  = Substitute.For <ITrackingValidation>();
            _dateFormatter       = Substitute.For <IDateFormatter>();

            _uut = new Objectifier(_transponderReceiver, _trackingValidation, _transponderParsing, _dateFormatter);

            _transponderArgsList = new List <string> {
                "ATR423;39045;12932;14000;20151006213456789"
            };
            _transponderDataEventArgs = new RawTransponderDataEventArgs(_transponderArgsList);

            _uut.TrackListReady += (sender, TrackListEventArgs) =>
            {
                _trackObjects = TrackListEventArgs.TrackObjects;
            };
        }
示例#24
0
        public void Setup()
        {
            _labelFormatter = Substitute.For <IHeaderLabelFormatter>();
            _labelFormatter.FormatLabel(TranslatedStrings.Author, Arg.Any <int>()).Returns(x => "Author:        ");
            _labelFormatter.FormatLabel(TranslatedStrings.Committer, Arg.Any <int>()).Returns(x => "Committer:     ");
            _labelFormatter.FormatLabel(TranslatedStrings.Date, Arg.Any <int>()).Returns(x => "Date:          ");
            _labelFormatter.FormatLabel(TranslatedStrings.AuthorDate, Arg.Any <int>()).Returns(x => "Author date:   ");
            _labelFormatter.FormatLabel(TranslatedStrings.CommitDate, Arg.Any <int>()).Returns(x => "Commit date:   ");
            _labelFormatter.FormatLabel(TranslatedStrings.CommitHash, Arg.Any <int>()).Returns(x => "Commit hash:   ");
            _labelFormatter.FormatLabel(TranslatedStrings.GetParents(1), Arg.Any <int>()).Returns(x => "Parent:        ");
            _labelFormatter.FormatLabel(TranslatedStrings.GetParents(Arg.Any <int>()), Arg.Any <int>()).Returns(x => "Parents:       ");
            _labelFormatter.FormatLabel(TranslatedStrings.GetChildren(1), Arg.Any <int>()).Returns(x => "Child:         ");
            _labelFormatter.FormatLabel(TranslatedStrings.GetChildren(Arg.Any <int>()), Arg.Any <int>()).Returns(x => "Children:      ");

            _headerRendererStyleProvider = Substitute.For <IHeaderRenderStyleProvider>();
            _linkFactory   = Substitute.For <ILinkFactory>();
            _dateFormatter = Substitute.For <IDateFormatter>();

            _renderer = new CommitDataHeaderRenderer(_labelFormatter, _dateFormatter, _headerRendererStyleProvider, _linkFactory);
        }
示例#25
0
        public void Init() {
            var builder = new ContainerBuilder();
            builder.RegisterType<StubOrchardServices>().As<IOrchardServices>();
            builder.RegisterType<TokenManager>().As<ITokenManager>();
            builder.RegisterType<Tokenizer>().As<ITokenizer>();
            builder.RegisterType<DateTokens>().As<ITokenProvider>();
            builder.RegisterType<StubClock>().As<IClock>();
            builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
            builder.RegisterType<SiteCalendarSelector>().As<ICalendarSelector>();
            builder.RegisterType<DefaultCalendarManager>().As<ICalendarManager>();
            builder.RegisterType<CultureDateTimeFormatProvider>().As<IDateTimeFormatProvider>();
            builder.RegisterType<DefaultDateFormatter>().As<IDateFormatter>();
            builder.RegisterType<DefaultDateLocalizationServices>().As<IDateLocalizationServices>();
 
            _container = builder.Build();
            _tokenizer = _container.Resolve<ITokenizer>();
            _clock = _container.Resolve<IClock>();
            _dateTimeFormats = _container.Resolve<IDateTimeFormatProvider>();
            _dateLocalizationServices = _container.Resolve<IDateLocalizationServices>();
            _dateFormatter = _container.Resolve<IDateFormatter>();
        }
示例#26
0
        public void Setup()
        {
            list1 = new List <string> {
                "MAR123", "50000", "50000", "1000", "20151006213456000"
            };
            list2 = new List <string> {
                "MAR123", "49900", "49900", "1000", "20151006213457000"
            };
            trackObject1 = new TrackObject(list1);
            trackObject2 = new TrackObject(list2);
            tList1       = new List <TrackObject> {
                trackObject1
            };
            tList2 = new List <TrackObject> {
                trackObject2
            };
            returnList            = new List <TrackObject>();
            _receivedTrackObjects = new List <TrackObject>();
            trackObject           = new TrackObject(list1);
            _trackObjects         = new List <TrackObject>();
            _trackObjects.Add(trackObject);
            distance                  = new Distance();
            _transponderReceiver      = Substitute.For <ITransponderReceiver>();
            _transponderParsing       = new TransponderParsing();
            _trackingValidation       = new TrackingValidation();
            _dateFormatter            = new DateFormatter();
            _velocityCourseCalculator = new VelocityCourseCalculater(distance);
            _trackUpdater             = new TrackUpdater(_velocityCourseCalculator);
            _separationChecker        = new SeparationChecker(distance);
            _print       = Substitute.For <IPrint>();
            _objectifier = Substitute.For <ITrackListEvent>();
            _uut         = new ATMSystem(_objectifier, _trackUpdater, _velocityCourseCalculator, _separationChecker, _print);
            _trackObjectDataEventArgs = new TrackListEventArgs(_trackObjects);

            _objectifier.TrackListReady += (sender, TrackListEventArgs) =>
            {
                _receivedTrackObjects = TrackListEventArgs.TrackObjects;
            };
        }
示例#27
0
        List <IDateFormatter> GetFormatters(string expression)
        {
            List <IDateFormatter> formatters = new List <IDateFormatter> ();

            foreach (string str in expression.Split(' '))
            {
                char token = char.MinValue;
                if (!char.TryParse(str, out token))
                {
                    continue;
                }

                TranslatableToken translatableToken = null;
                if (!translatableTokens.TryGetValue(token,
                                                    out translatableToken))
                {
                    continue;
                }

                if (translatableToken.Formatter == null)
                {
                    continue;
                }

                IDateFormatter formatter = DateFormatterFactory
                                           .Instance.Get(translatableToken.Formatter);
                if (!formatters.Contains(formatter))
                {
                    formatters.Add(formatter);
                }
            }
            if (formatters.Count == 0)
            {
                throw new Exception("No formatters");
            }

            return(formatters);
        }
示例#28
0
        public void Init()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <StubOrchardServices>().As <IOrchardServices>();
            builder.RegisterType <TokenManager>().As <ITokenManager>();
            builder.RegisterType <Tokenizer>().As <ITokenizer>();
            builder.RegisterType <DateTokens>().As <ITokenProvider>();
            builder.RegisterType <StubClock>().As <IClock>();
            builder.RegisterType <StubWorkContextAccessor>().As <IWorkContextAccessor>();
            builder.RegisterType <SiteCalendarSelector>().As <ICalendarSelector>();
            builder.RegisterType <DefaultCalendarManager>().As <ICalendarManager>();
            builder.RegisterType <CultureDateTimeFormatProvider>().As <IDateTimeFormatProvider>();
            builder.RegisterType <DefaultDateFormatter>().As <IDateFormatter>();
            builder.RegisterType <DefaultDateLocalizationServices>().As <IDateLocalizationServices>();

            _container                = builder.Build();
            _tokenizer                = _container.Resolve <ITokenizer>();
            _clock                    = _container.Resolve <IClock>();
            _dateTimeFormats          = _container.Resolve <IDateTimeFormatProvider>();
            _dateLocalizationServices = _container.Resolve <IDateLocalizationServices>();
            _dateFormatter            = _container.Resolve <IDateFormatter>();
        }
示例#29
0
        /// <summary>
        /// Initialize the converter options
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="IOptionHandler"/> delayed object
        /// activation scheme. The <see cref="ActivateOptions"/> method must
        /// be called on this object after the configuration properties have
        /// been set. Until <see cref="ActivateOptions"/> is called this
        /// object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then
        /// <see cref="ActivateOptions"/> must be called again.
        /// </para>
        /// </remarks>
        public void ActivateOptions()
        {
            string dateFormatStr = Option;

            if (dateFormatStr == null)
            {
                dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
            }

            string dateFormatStrUpper = dateFormatStr.ToUpperInvariant();

            if (dateFormatStrUpper == AbsoluteTimeDateFormatter.Iso8601TimeDateFormat.ToUpperInvariant())
            {
                m_dateFormatter = new Iso8601DateFormatter();
            }
            else if (dateFormatStrUpper == AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat.ToUpperInvariant())
            {
                m_dateFormatter = new AbsoluteTimeDateFormatter();
            }
            else if (dateFormatStrUpper == AbsoluteTimeDateFormatter.DateAndTimeDateFormat.ToUpperInvariant())
            {
                m_dateFormatter = new DateTimeDateFormatter();
            }
            else
            {
                try
                {
                    m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
                }
                catch (Exception e)
                {
                    LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]", e);
                    m_dateFormatter = new Iso8601DateFormatter();
                }
            }
        }
		/// <summary>
		/// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
		/// </summary>
		/// <remarks>
		/// <para>
		/// This is part of the <see cref="IOptionHandler"/> delayed object
		/// activation scheme. The <see cref="ActivateOptions"/> method must 
		/// be called on this object after the configuration properties have
		/// been set. Until <see cref="ActivateOptions"/> is called this
		/// object is in an undefined state and must not be used. 
		/// </para>
		/// <para>
		/// If any of the configuration properties are modified then 
		/// <see cref="ActivateOptions"/> must be called again.
		/// </para>
		/// </remarks>
		public void ActivateOptions()
		{
			string dateFormatStr = Option;
			if (dateFormatStr == null)
			{
				dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
			}
			
			if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0) 
			{
				m_dateFormatter = new Iso8601DateFormatter();
			}
			else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
			{
				m_dateFormatter = new AbsoluteTimeDateFormatter();
			}
			else if (string.Compare(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
			{
				m_dateFormatter = new DateTimeDateFormatter();
			}
			else 
			{
				try 
				{
					m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
				}
				catch (Exception e) 
				{
					LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
					m_dateFormatter = new Iso8601DateFormatter();
				}	
			}
		}
 /// <summary>
 /// Construct the converter with formatting info and a
 /// <see cref="IDateFormatter"/> to format the date
 /// </summary>
 /// <param name="formattingInfo">the formatting info</param>
 /// <param name="df">the date formatter</param>
 internal DatePatternConverter(FormattingInfo formattingInfo, IDateFormatter df) : base(formattingInfo)
 {
     m_df = df;
 }
示例#32
0
 public TimestampedLogFormatter()
 {
     _dateFormatter = new UtcDateFormatter();
 }
			/// <summary>
			/// Construct the converter with formatting info and a
			/// <see cref="IDateFormatter"/> to format the date
			/// </summary>
			/// <param name="formattingInfo">the formatting info</param>
			/// <param name="df">the date formatter</param>
			internal DatePatternConverter(FormattingInfo formattingInfo, IDateFormatter df) : base(formattingInfo)
			{
				m_df = df;	  
			}
示例#34
0
 public void Setup()
 {
     _uut = new DateFormatter();
 }
示例#35
0
 public ConsoleOutputPrinter(IDateFormatter dateFormatter)
 {
     _dateFormatter = dateFormatter;
 }
示例#36
0
 public Application(IDateFormatter dateFormatter)
 {
     this.dateFormatter = dateFormatter;
 }
示例#37
0
 public OutputSTDOut([KeyFilter("long")] IDateFormatter formatter, [KeyFilter("stdLog")] TextWriter writer)
 {
     this.formatter = formatter;
     this.writer    = writer;
 }