Exemple #1
0
        public virtual void Configure(IConfigSectionNode config)
        {
            if (Disposed)
            {
                return;
            }

            if (config == null)
            {
                return;
            }
            ConfigAttribute.Apply(this, config);

            var loc = config[TimeLocation.CONFIG_TIMELOCATION_SECTION];

            if (loc.Exists)
            {
                m_TimeLocation = FactoryUtils.MakeAndConfigure <TimeLocation>(loc, typeof(TimeLocation));
            }

            var ehnode = config[CONFIG_HANDLER_SECTION];

            if (ehnode.Exists)
            {
                EventHandler = FactoryUtils.MakeUsingCtor <IEventHandler>(ehnode);
            }
        }
Exemple #2
0
        public void T4()
        {
            using(var app = new ServiceBaseApplication(null, CONFIG1.AsLaconicConfig()))
            {
              Assert.AreEqual(150, app.EventTimer.ResolutionMs);

              var lst = new List<string>();

              var limpopoTime = new TimeLocation(new TimeSpan(0, 0, 2), "Limpopo Time is 2 seconds ahead of UTC");

              var utcNow = app.TimeSource.UTCNow;

              Console.WriteLine( utcNow.Kind );

              new Event(app.EventTimer, "A", (e) => {lock(lst) lst.Add("a");}, new TimeSpan(0,0,1)) { TimeLocation = limpopoTime, StartDate = utcNow.AddSeconds(-2) };
              new Event(app.EventTimer, "B", (e) => {lock(lst) lst.Add("b");}, new TimeSpan(0,0,3)) { TimeLocation = TimeLocation.UTC, StartDate = utcNow };

              Thread.Sleep(10000);

              app.EventTimer.Events["A"].Dispose();
              app.EventTimer.Events["B"].Dispose();

              Assert.AreEqual(0, app.EventTimer.Events.Count);

              Console.WriteLine(string.Join(" , ", lst));
              Assert.AreEqual(10, lst.Count(s=>s=="a"));
              Assert.AreEqual(4, lst.Count(s=>s=="b"));
            }
        }
Exemple #3
0
      public virtual void Configure(IConfigSectionNode config)
      {
        if (Disposed) return;

        if (config==null) return;
        ConfigAttribute.Apply(this, config);

        var loc = config[TimeLocation.CONFIG_TIMELOCATION_SECTION];
        if (loc.Exists) 
          m_TimeLocation = FactoryUtils.MakeAndConfigure<TimeLocation>(loc, typeof(TimeLocation));

        var ehnode = config[CONFIG_HANDLER_SECTION];
        if (ehnode.Exists) 
          EventHandler = FactoryUtils.MakeUsingCtor<IEventHandler>(ehnode);
      }