Beispiel #1
0
        /// <summary>
        /// Performs all BAM actions for a BAM steps in a specified directive.  This method can
        /// optionally handle step processing after application of a map.
        /// </summary>
        /// <param name="directiveName">The name of the directive that defines the BAM step.</param>
        /// <param name="data">The BAM step data.</param>
        /// <param name="afterMap">Indicates if the step is after the application of a map.</param>
        public void OnStep(string directiveName, BamStepData data, bool afterMap)
        {
            var firstBamDirective = this.items.FirstOrDefault(directive => directive.Name == directiveName);

            if (firstBamDirective != null)
            {
                firstBamDirective.OnStep(data, afterMap);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Retrieves data for a particular step of a BAM activity for the first directive found that
        /// defines a step.    Call this method on every step in which some data may be needed for BAM
        /// - e.g., at the point a service is called, or at the point of resolution.
        /// </summary>
        /// <param name="data">The BAM step data.</param>
        /// <param name="afterMap">Indicates if the step is after the application of a map.</param>
        private void OnFirstStep(BamStepData data, bool afterMap)
        {
            var firstBamDirective = this.items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.BamStepName))
                                    ?? this.items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.BamAfterMapStepName));

            if (firstBamDirective != null)
            {
                firstBamDirective.OnStep(data, afterMap);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Performs all BAM actions for configured BAM steps in either the first or all
        /// the directives.  Optionally perform BAM actions for all step extensions.
        /// This method can optionally handle step processing after application of a map.
        /// </summary>
        /// <param name="data">The BAM step data.</param>
        /// <param name="depth">
        /// Specify the depth of BAM processing; first or all steps and, optionally,
        /// each step extension.
        /// </param>
        /// <param name="afterMap">Indicates if the step is after the application of a map.</param>
        public void OnStep(BamStepData data, MultiStepControl depth, bool afterMap)
        {
            switch (depth)
            {
            case MultiStepControl.AllSteps:
                foreach (var bamDirective in this.items)
                {
                    bamDirective.OnStep(data, afterMap);
                }

                break;

            case MultiStepControl.AllStepsWithExtensions:
                foreach (var bamDirective in this.items)
                {
                    bamDirective.OnStep(data, afterMap);

                    foreach (var extension in bamDirective.BamStepExtensions)
                    {
                        var eventStream = new TrackpointDirectiveEventStream(bamDirective, data);
                        eventStream.SelectBamStepExtension(extension, afterMap);
                        bamDirective.EventStream = eventStream;
                        bamDirective.OnStep(data, afterMap);
                    }
                }

                break;

            case MultiStepControl.FirstStepOnly:
                this.OnFirstStep(data, afterMap);
                break;

            case MultiStepControl.FirstStepWithExtensions:
                var firstBamDirective = this.items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.BamStepName))
                                        ?? this.items.FirstOrDefault(item => !string.IsNullOrWhiteSpace(item.BamAfterMapStepName));

                if (firstBamDirective != null)
                {
                    firstBamDirective.OnStep(data, afterMap);

                    foreach (var extension in firstBamDirective.BamStepExtensions)
                    {
                        var eventStream = new TrackpointDirectiveEventStream(firstBamDirective, data);
                        eventStream.SelectBamStepExtension(extension, afterMap);
                        firstBamDirective.EventStream = eventStream;
                        firstBamDirective.OnStep(data, afterMap);
                    }
                }

                break;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Performs all BAM actions for a BAM steps in a specified directive.
 /// </summary>
 /// <param name="directiveName">The name of the directive that defines the BAM step.</param>
 /// <param name="data">The BAM step data.</param>
 public void OnStep(string directiveName, BamStepData data)
 {
     this.OnStep(directiveName, data, false);
 }
Beispiel #5
0
 /// <summary>
 /// Performs all BAM actions for configured BAM steps in either the first or
 /// all the directives.  Optionally perform BAM actions for all step extensions.
 /// </summary>
 /// <param name="data">The BAM step data.</param>
 /// <param name="depth">
 /// Specify the depth of BAM processing; first or all steps and, optionally,
 /// each step extension.
 /// </param>
 public void OnStep(BamStepData data, MultiStepControl depth)
 {
     this.OnStep(data, depth, false);
 }
Beispiel #6
0
 /// <summary>
 /// Performs all BAM actions for configured BAM steps in all the directives.  This method
 /// can optionally handle step processing after application of a map.
 /// </summary>
 /// <param name="data">The BAM step data.</param>
 /// <param name="afterMap">Indicates if the step is after the application of a map.</param>
 public void OnStep(BamStepData data, bool afterMap)
 {
     this.OnStep(data, MultiStepControl.AllSteps, afterMap);
 }
Beispiel #7
0
 /// <summary>
 /// Performs all BAM actions for configured BAM steps in all the directives.
 /// </summary>
 /// <param name="data">The BAM step data.</param>
 public void OnStep(BamStepData data)
 {
     this.OnStep(data, MultiStepControl.AllSteps, false);
 }
Beispiel #8
0
        /// <summary>
        /// Transform the message by applying a map.   Invoke BAM interception as required.
        /// </summary>
        /// <param name="messageIn">
        /// The inbound message.
        /// </param>
        /// <param name="messageProperties">A dictionary of message properties.</param>
        /// <returns>
        /// A transformed XML document.
        /// </returns>
        private XmlDocument DoTransformWithInterception(XmlDocument messageIn, IDictionary messageProperties)
        {
            if (this.directive == null)
            {
                return(messageIn);
            }

            // [var] A value indicating whether interception is required.
            var doInterception = this.directive.DirectiveCategories.Contains("BamInterception");

            // Perform any required pre-transformation interception.
            if (doInterception && !string.IsNullOrEmpty(this.directive.BamStepName))
            {
                var stepDataBefore = new BamStepData {
                    XmlDocument = messageIn
                };
                foreach (var messagePropertyKey in messageProperties.Keys)
                {
                    if (stepDataBefore.Properties.Contains(messagePropertyKey))
                    {
                        stepDataBefore.Properties[messagePropertyKey] = messageProperties[messagePropertyKey];
                    }
                    else
                    {
                        stepDataBefore.Properties.Add(messagePropertyKey, messageProperties[messagePropertyKey]);
                    }
                }

                this.OnStep(stepDataBefore);
            }

            // [var] The transformed message
            var transformedMessage = new XmlDocument();

            // If there is no XML content, then we cannot perform any transformation
            if (messageIn != null && messageIn.HasChildNodes)
            {
                // We will only transform and do a post-transformation BAM interception if a
                // transformation has been defined.
                if (!this.directive.DirectiveCategories.Contains("Transformation"))
                {
                    return(messageIn);
                }

                transformedMessage = this.Transform(messageIn);
            }

            // Return the transformed message if no post-transformation interception is required.
            if (!doInterception || string.IsNullOrEmpty(this.directive.BamAfterMapStepName))
            {
                return(transformedMessage);
            }

            // Perform post-transformation interception
            var stepDataAfter = new BamStepData
            {
                XmlDocument =
                    transformedMessage.HasChildNodes
                                                ? transformedMessage
                                                : messageIn
            };

            foreach (var messagePropertyKey in messageProperties.Keys)
            {
                if (stepDataAfter.Properties.Contains(messagePropertyKey))
                {
                    stepDataAfter.Properties[messagePropertyKey] = messageProperties[messagePropertyKey];
                }
                else
                {
                    stepDataAfter.Properties.Add(messagePropertyKey, messageProperties[messagePropertyKey]);
                }
            }

            this.OnStep(stepDataAfter, true);

            // Return the transformed message
            return(transformedMessage);
        }
Beispiel #9
0
 /// <summary>
 /// Performs all BAM actions for a configured BAM step.  This method can optionally
 /// handle step processing after application of a map.
 /// </summary>
 /// <param name="data">The BAM step data.</param>
 /// <param name="afterMap">Indicates if the step is after the application of a map.</param>
 public virtual void OnStep(BamStepData data, bool afterMap)
 {
     this.DoOnStep(data.XmlDocument, data.Properties, data.ValueList, afterMap);
 }
Beispiel #10
0
 /// <summary>
 /// Performs all BAM actions for a configured BAM step.
 /// </summary>
 /// <param name="data">The BAM step data.</param>
 public virtual void OnStep(BamStepData data)
 {
     this.DoOnStep(data.XmlDocument, data.Properties, data.ValueList, false);
 }