/// <summary> /// Promotes/writes the specified set of properties into the message context. /// </summary> /// <param name="pipelineContext">Pipeline context</param> /// <param name="inputMessage">Input message</param> /// <returns>Original input message</returns> protected override IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage inputMessage) { if (this.ContextProperties != null && this.ContextProperties.Count > 0) { // set the dynamic expression context required for ContextProperty properties of type "Expression" ExpressionData expressionData = new ExpressionData(inputMessage); this.ExpressionContext = new Expressions.ExpressionContext(ExpressionImports, expressionData); // iterate through all context properties promoting or writing foreach (ContextProperty contextProperty in this.ContextProperties) { object value = this.GetPropertyValue(inputMessage, contextProperty); if (contextProperty.IgnoreNullOrEmptyValue == false || this.IsNullOrEmptyValue(value) == false) { if (contextProperty.Promote == true) { TraceProvider.Logger.TraceInfo("Promoting property into context: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); inputMessage.Context.Promote(contextProperty.Name, contextProperty.Namespace, value); } else { TraceProvider.Logger.TraceInfo("Writing property into context: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); inputMessage.Context.Write(contextProperty.Name, contextProperty.Namespace, value); } } else { TraceProvider.Logger.TraceInfo("Ignoring null or empty value: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); } } } return(inputMessage); }
public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage inputMessage, string objectArguement) { var callToken = TraceProvider.Logger.TraceIn(this.Name); try { Guard.ArgumentNotNull(objectArguement, "objectArguement"); // set the dynamic expression context required for ContextProperty properties of type "Expression" ExpressionData expressionData = new ExpressionData(inputMessage); this.ExpressionContext = new Expressions.ExpressionContext(ExpressionImports, expressionData); ContextPropertySerializer ser = new ContextPropertySerializer(); ser.Deserialize(objectArguement); // iterate through all context properties promoting or writing foreach (ContextProperty contextProperty in ser.Properties) { object value = this.GetPropertyValue(pipelineContext, inputMessage, contextProperty); if (contextProperty.IgnoreNullOrEmptyValue == false || this.IsNullOrEmptyValue(value) == false) { if (contextProperty.Promote == true) { TraceProvider.Logger.TraceInfo("Promoting property into context: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); inputMessage.Context.Promote(contextProperty.Name, contextProperty.Namespace, value); } else { TraceProvider.Logger.TraceInfo("Writing property into context: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); inputMessage.Context.Write(contextProperty.Name, contextProperty.Namespace, value); } } else { TraceProvider.Logger.TraceInfo("Ignoring null or empty value: {0} = {1}; Namespace = {2}, Source = {3}", contextProperty.Name, value, contextProperty.Namespace, contextProperty.Source.ToString()); } } return(inputMessage); } catch (Exception ex) { // put component name as a source information in this exception, // so the event log in message could reflect this ex.Source = this.Name; TraceProvider.Logger.TraceError(ex); throw ex; } finally { TraceProvider.Logger.TraceOut(callToken, this.Name); } }