Exemple #1
0
        /// <summary>
        /// Load component properties from a property bag.
        /// </summary>
        /// <param name="propertyBag">Property bag</param>
        /// <param name="errorLog">Error log level</param>
        protected override void LoadProperties(IPropertyBag propertyBag, int errorLog)
        {
            string xml = this.ReadPropertyValue <string>(propertyBag, PROPERTIES_PROP_NAME, null);

            if (string.IsNullOrEmpty(xml) == false)
            {
                ContextPropertySerializer serializer = new ContextPropertySerializer();
                serializer.Deserialize(xml);
                this.ContextProperties = serializer.Properties;
            }
        }
Exemple #2
0
        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);
            }
        }