示例#1
0
 /// <summary>
 /// Returns true if the current plugin maps to the parameters given, or the current plugin has been triggered by the given parameters
 /// </summary>
 /// <returns></returns>
 public static bool CalledFrom(this IPluginExecutionContext context, string entityLogicalName = null, MessageType message = null, int?stage = null)
 {
     if (message == null && entityLogicalName == null && stage == null)
     {
         throw new Exception("At least one parameter for IPluginExecutionContext.CalledFrom must be populated");
     }
     return(context.GetContexts().Any(c =>
                                      (message == null || c.MessageName == message.Name) &&
                                      (entityLogicalName == null || c.PrimaryEntityName == entityLogicalName) &&
                                      (stage == null || c.Stage == stage.Value)));
 }
示例#2
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));
 }