示例#1
0
文件: Event.cs 项目: erxdkh/azos
        public Event(IEventTimer timer,
                     string name                        = null,
                     TimerEvent body                    = null,
                     TimeSpan?interval                  = null,
                     IConfigSectionNode config          = null,
                     EventBodyAsyncModel bodyAsyncModel = EventBodyAsyncModel.AsyncTask,
                     bool enabled                       = true) : base(timer)
        {
            if ((timer as IEventTimerImplementation) == null)
            {
                throw new TimeException(StringConsts.ARGUMENT_ERROR + "Event.ctor(timer=null | timer!=IEventTimerImplementation)");
            }

            m_Enabled = enabled;

            m_Timer = timer;

            if (body != null)
            {
                Body += body;
            }

            if (interval.HasValue)
            {
                m_Interval = interval.Value;
            }

            BodyAsyncModel = bodyAsyncModel;

            if (config != null)
            {
                Configure(config);
                m_Name = config.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            }

            if (name.IsNotNullOrWhiteSpace())
            {
                m_Name = name;
            }

            if (m_Name.IsNullOrWhiteSpace())
            {
                m_Name = Guid.NewGuid().ToString();
            }

            ((IEventTimerImplementation)timer).__InternalRegisterEvent(this);
        }
示例#2
0
文件: Event.cs 项目: itadapter/nfx
        public Event(IEventTimer timer, string name = null, TimerEvent body = null, TimeSpan? interval = null, IConfigSectionNode config = null, EventBodyAsyncModel bodyAsyncModel = EventBodyAsyncModel.AsyncTask)
            : base(timer)
        {
            if ((timer as IEventTimerImplementation) == null)
              throw new TimeException(StringConsts.ARGUMENT_ERROR + "Event.ctor(timer=null | timer!=IEventTimerImplementation)");

             m_Timer = timer;

             if (body!=null)
              Body += body;

             if (interval.HasValue)
              m_Interval = interval.Value;

             BodyAsyncModel = bodyAsyncModel;

             if (config!=null)
             {
               Configure(config);
               m_Name = config.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
             }

             if (name.IsNotNullOrWhiteSpace())
               m_Name = name;

             if (m_Name.IsNullOrWhiteSpace()) m_Name = Guid.NewGuid().ToString();

             ((IEventTimerImplementation)timer).__InternalRegisterEvent(this);
        }