/// <summary> /// Gets the property value based on the context property source. /// </summary> /// <param name="inputMessage">Instance of the input message.</param> /// <param name="contextProperty">Instance of the context property.</param> /// <returns>Property value.</returns> private object GetPropertyValue(IBaseMessage inputMessage, ContextProperty contextProperty) { // evaluate property object value = null; switch (contextProperty.Source) { case ContextPropertySource.Literal: // literal value specified in the Value field value = contextProperty.Value; break; case ContextPropertySource.Context: // read the value from the message context value = inputMessage.Context.Read(contextProperty.Name, contextProperty.Namespace); break; case ContextPropertySource.Expression: // evaluate the expression defined by the context property var expression = new Expressions.DynamicExpression(contextProperty.Value, Expressions.ExpressionLanguage.Csharp); value = expression.Invoke(this.ExpressionContext); break; } return(value); }
/// <summary> /// Gets the property value based on the context property source. /// </summary> /// <param name="inputMessage">Instance of the input message.</param> /// <param name="contextProperty">Instance of the context property.</param> /// <returns>Property value.</returns> private object GetPropertyValue(IPipelineContext pipelineContext, IBaseMessage inputMessage, GT.BizTalk.Framework.BizTalk.Serialization.ContextProperty contextProperty) { // evaluate property object value = null; switch (contextProperty.Source) { case GT.BizTalk.Framework.BizTalk.Serialization.ContextPropertySource.Literal: // literal value specified in the Value field value = Convert.ChangeType(contextProperty.Value, Type.GetType(contextProperty.DataType)); break; case GT.BizTalk.Framework.BizTalk.Serialization.ContextPropertySource.Context: // read the value from the message context //value = inputMessage.Context.Read(contextProperty.Name, contextProperty.Namespace); var nns = contextProperty.Value.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); value = inputMessage.Context.Read(nns[1], nns[0]); break; case GT.BizTalk.Framework.BizTalk.Serialization.ContextPropertySource.Expression: // evaluate the expression defined by the context property var expression = new Expressions.DynamicExpression(contextProperty.Value, Expressions.ExpressionLanguage.Csharp); value = expression.Invoke(this.ExpressionContext); break; case GT.BizTalk.Framework.BizTalk.Serialization.ContextPropertySource.XPath: // read the value from the message context value = GetXPathValue(pipelineContext, inputMessage, contextProperty.Value); break; } return(value); }