Exemplo n.º 1
0
        /// <summary>
        /// Use repository to build new QueueItem and fill it with various data
        /// </summary>
        /// <param name="eventInstance"></param>
        /// <param name="queueType"></param>
        /// <param name="handleAfter"></param>
        protected virtual void AddEventHandler(object eventInstance, Type queueType, TimeSpan handleAfter)
        {
            var item = _repository.BuildNewItem(eventInstance);

            item.HandleAfter = DateTime.Now.Add(handleAfter);
            // storing only type name and assembly name, otherwise it will be impossible to deserialise object with newer assembly
            item.DeclaringEventType = queueType.AssemblyQualifiedName;

            onAddEvent(item, eventInstance);

            _repository.AddItem(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Use repository to build new QueueItem and fill it with various data
        /// </summary>
        /// <param name="eventInstance"></param>
        /// <param name="queueType"></param>
        /// <param name="handlingDelay"></param>
        protected virtual void AddEventHandler(object eventInstance, Type queueType, TimeSpan handlingDelay)
        {
            var item = _repository.BuildNewItem(eventInstance);
            var eventAsHandleAfter = eventInstance as IHandleAfter;

            if (eventAsHandleAfter != null && handlingDelay != TimeSpan.Zero)
            {
                throw new InvalidOperationException("Events which implements IHandleAfter cannot support handlingDelay");
            }
            item.HandleAfter = eventAsHandleAfter != null ? eventAsHandleAfter.HandleAfter : DateTime.Now.Add(handlingDelay);
            // storing only type name and assembly name, otherwise it will be impossible to deserialise object with newer assembly
            item.DeclaringEventType = queueType.AssemblyQualifiedName;

            onAddEvent(item, eventInstance);

            _repository.AddItem(item);
        }