/// <summary>
        /// Determines whether a shared variable exists that specifies that the plugin or the plugin and specifc message type should be prevented from executing
        /// </summary>
        /// <typeparam name="T">The type of the plugin.</typeparam>
        /// <returns></returns>
        public bool HasPluginHandlerExecutionBeenPrevented <T>(RegisteredEvent @event)
            where T : IRegisteredEventsPluginHandler
        {
            var preventionName = GetPreventPluginHandlerSharedVariableName(typeof(T).FullName);

            return(HasPluginHandlerExecutionBeenPreventedInternal(@event, preventionName));
        }
        /// <summary>
        /// Adds a shared Variable to the context that is checked by the GenericPluginHandlerBase to determine if it should be skipped  * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin
        /// </summary>
        /// <param name="handlerTypeFullName">The Full Type Name of the Plugin to Prevent</param>
        /// <param name="event">Type of the event.</param>
        public void PreventPluginHandlerExecution(String handlerTypeFullName, RegisteredEvent @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException("event");
            }

            PreventPluginHandlerExecution(handlerTypeFullName, @event.MessageName, @event.EntityLogicalName, @event.Stage);
        }
        private bool HasPluginHandlerExecutionBeenPreventedInternal(RegisteredEvent @event, string preventionName)
        {
            var value = GetFirstSharedVariable(preventionName);

            if (value == null)
            {
                return(false);
            }

            var hash = ((Entity)value).Attributes;

            return(hash.Contains(String.Empty) ||
                   hash.Contains(GetPreventionRule(@event.MessageName)) ||
                   hash.Contains(GetPreventionRule(@event.MessageName, @event.EntityLogicalName)) ||
                   hash.Contains(GetPreventionRule(@event.MessageName, stage: @event.Stage)) ||
                   hash.Contains(GetPreventionRule(@event.MessageName, @event.EntityLogicalName, @event.Stage)) ||
                   hash.Contains(GetPreventionRule(logicalName: @event.EntityLogicalName)) ||
                   hash.Contains(GetPreventionRule(logicalName: @event.EntityLogicalName, stage: @event.Stage)) ||
                   hash.Contains(GetPreventionRule(stage: @event.Stage)));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a shared Variable to the context that is checked by the GenericPluginHandlerBase to determine if it should be skipped  * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin
 /// </summary>
 /// <typeparam name="T">The type of the plugin.</typeparam>
 /// <param name="context">The context.</param>
 /// <param name="event">Type of the event.</param>
 public static void PreventPluginHandlerExecution <T>(this IPluginExecutionContext context, RegisteredEvent @event)
     where T : IRegisteredEventsPluginHandler
 {
     context.PreventPluginHandlerExecution(typeof(T).FullName, @event);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds a shared Variable to the context that is checked by the GenericPluginHandlerBase to determine if it should be skipped  * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="handlerTypeFullName">The Full Type Name of the Plugin to Prevent</param>
        /// <param name="event">Type of the event.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static void PreventPluginHandlerExecution(this IPluginExecutionContext context, string handlerTypeFullName, RegisteredEvent @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }

            context.PreventPluginHandlerExecution(handlerTypeFullName, @event.MessageName, @event.EntityLogicalName, @event.Stage);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns true if the current plugin maps to the Registered Event, or the current plugin has been triggered by the given registered event
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="event">The event.</param>
 /// <returns></returns>
 public static bool CalledFrom(this IPluginExecutionContext context, RegisteredEvent @event)
 {
     return(context.GetContexts().Any(c => c.MessageName == @event.MessageName && c.PrimaryEntityName == @event.EntityLogicalName && c.Stage == (int)@event.Stage));
 }
 /// <summary>
 /// Adds a shared Variable to the context that is checked by the GenericPluginHandlerBase to determine if it should be skipped  * NOTE * The Plugin has to finish executing for the Shared Variable to be passed to a new plugin
 /// </summary>
 /// <typeparam name="T">The type of the plugin.</typeparam>
 /// <param name="event">Type of the event.</param>
 public void PreventPluginHandlerExecution <T>(RegisteredEvent @event)
     where T : IRegisteredEventsPluginHandler
 {
     PreventPluginHandlerExecution(typeof(T).FullName, @event);
 }
 /// <summary>
 /// Returns true if the current plugin maps to the Registered Event, or the current plugin has been triggered by the given registered event
 /// </summary>
 /// <param name="event"></param>
 /// <returns></returns>
 public bool CalledFrom(RegisteredEvent @event)
 {
     return(Contexts.Any(c => c.MessageName == @event.MessageName && c.PrimaryEntityName == @event.EntityLogicalName && c.Stage == (int)@event.Stage));
 }