Esempio n. 1
0
        /// <summary>
        /// Publish modify event
        /// </summary>
        /// <param name="eventSource">Event source type</param>
        /// <param name="eventType">Event type</param>
        /// <param name="query">Query</param>
        /// <param name="activationOptions">Activation options</param>
        /// <param name="callback">Callback</param>
        public static void PublishModify <TObject>(Type eventSource, IModify modify, IQuery query, ActivationOptions activationOptions = null, RepositoryEventCallback callback = null)
        {
            var eventHandlers = GetEventHandlers(eventSource, EventType.ModifyExpression, typeof(TObject));

            if (!eventHandlers.IsNullOrEmpty())
            {
                foreach (var handler in eventHandlers)
                {
                    ModifyEventHandler eventHandler = handler as ModifyEventHandler;
                    if (eventHandler == null)
                    {
                        continue;
                    }
                    eventHandler.Execute(modify, query, activationOptions);
                }
            }
            callback?.Invoke(DataOperationEventExecuteResult.Empty);
        }
        /// <summary>
        /// publish modify
        /// </summary>
        /// <param name="eventSource">event source</param>
        /// <param name="eventType">event type</param>
        /// <param name="query">query</param>
        /// <param name="callback">callback</param>
        public static void PublishModify <T>(Type eventSource, IModify modify, IQuery query, RepositoryEventCallback callback = null)
        {
            if (modify == null)
            {
                return;
            }
            var eventHandlers = GetEventHandlers(eventSource, EventType.ModifyExpression, typeof(T));

            if (eventHandlers.IsNullOrEmpty())
            {
                callback?.Invoke(DataOperationEventResult.Empty);
                return;
            }
            foreach (var handler in eventHandlers)
            {
                ModifyEventHandler eventHandler = handler as ModifyEventHandler;
                if (eventHandler == null)
                {
                    continue;
                }
                eventHandler.Execute(modify, query);
            }
            callback?.Invoke(DataOperationEventResult.Empty);
        }