protected virtual void OnPipelineEventFiring(PipelineEventFiringEventArgs e) { if (this.PipelineEventFiring != null) { this.PipelineEventFiring(this, e); } }
public void Execute(PipelineContext <TContext> pipelineEvent, TContext context, TransactionScopeOption transactionScope) { Contract.Requires(pipelineEvent != null); Contract.Requires(context != null); Definition.Pipeline pipeline = GetPipelineDefinition(); System.Transactions.TransactionScopeOption scopeOption = GetTransactionScopeOption(transactionScope); if (pipelineEvent != null) { using (TransactionScope eventScope = new TransactionScope(scopeOption)) { PipelineEventFiringEventArgs args = new PipelineEventFiringEventArgs(pipeline.Name); OnPipelineEventFiring(args); if (!args.Cancel) { if (pipeline.InvokeAll) { if (pipelineEvent != null) { pipelineEvent(context); } } else { Delegate[] list = pipelineEvent.GetInvocationList(); foreach (PipelineContext <TContext> item in list) { item(context); if (context.Cancel) { break; } } } OnPipelineEventFired(new PipelineEventFiredEventArgs(pipeline.Name)); } eventScope.Complete(); } } }
public void Execute(TEvents pipelineEvents, TContext context) { Contract.Requires(pipelineEvents != null); Contract.Requires(context != null); Definition.Pipeline pipeline = GetPipelineDefinition(); PropertyInfo[] properties = pipelineEvents.GetType().GetProperties(); List <PropertyInfo> sortedProperties = properties.ToList <PropertyInfo>(); sortedProperties.Sort(new PropertyComparer()); System.Transactions.TransactionScopeOption pipelineScopeOption = TransactionRequirement(sortedProperties); using (TransactionScope pipelineScope = new TransactionScope(pipelineScopeOption)) { sortedProperties.ForEach(property => { object[] attributes = property.GetCustomAttributes(typeof(PipelineEventAttribute), true); if (attributes.Length > 0) { PipelineEventAttribute attr = (PipelineEventAttribute)attributes[0]; System.Transactions.TransactionScopeOption scopeOption = GetTransactionScopeOption(attr.TransactionScopeOption); object value = property.GetValue(pipelineEvents, null); PipelineContext <TContext> eventProp = (PipelineContext <TContext>)value; if (eventProp != null) { using (TransactionScope eventScope = new TransactionScope(scopeOption)) { PipelineEventFiringEventArgs args = new PipelineEventFiringEventArgs(pipeline.Name, property.Name); OnPipelineEventFiring(args); if (!args.Cancel) { if (pipeline.InvokeAll) { if (eventProp != null) { eventProp(context); } } else { Delegate[] list = eventProp.GetInvocationList(); foreach (PipelineContext <TContext> item in list) { item(context); if (context.Cancel) { break; } } } OnPipelineEventFired(new PipelineEventFiredEventArgs(pipeline.Name, property.Name)); } eventScope.Complete(); } } } }); pipelineScope.Complete(); } }