コード例 #1
0
        /// <summary>
        /// Executes the specified resolution policy and returns the results
        /// in an instance of a MessageContextAccessorResolver object.
        /// </summary>
        /// <param name="message">The IBaseMessage instace.</param>
        /// <returns>MessageContextAccessorResolver instance containing the resolution results.</returns>
        public MessageContextAccessorResolver Resolve(IBaseMessage message)
        {
            // extract context properties
            Dictionary <string, object> contextProperties = new Dictionary <string, object>();

            message.Context.ReadAll(contextProperties);
            for (int p = 0; p < message.PartCount; p++)
            {
                string partName = string.Empty;
                var    part     = message.GetPartByIndex(p, out partName);
                part.PartProperties.ReadAll(contextProperties);
            }

            // create a fact instance
            MessageContextAccessorResolver fact = new MessageContextAccessorResolver(contextProperties);

            if (string.IsNullOrEmpty(this.PolicyName))
            {
                return(fact);
            }

            // execute the schema resolution policy
            using (Policy policy = new Policy(this.PolicyName, this.MajorRevision, this.MinorRevision))
            {
                object[] facts = { fact };
                BRETrackingInterceptor interceptor = new BRETrackingInterceptor();
                policy.Execute(facts, interceptor);
                return(fact);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the next message from the message set resulting from the disassembler execution.
        /// </summary>
        /// <param name="pipelineContext">The IPipelineContext containing the current pipeline context.</param>
        /// <returns>
        /// A pointer to the IBaseMessage containing the next message from the disassembled document.
        /// Returns NULL if there are no more messages left.
        /// </returns>
        public IBaseMessage GetNext(IPipelineContext pipelineContext)
        {
            var callToken = TraceProvider.Logger.TraceIn(this.Name);

            try
            {
                if (outMsgQueue.Count > 0)
                {
                    var outMsg = outMsgQueue.Dequeue();

                    TraceProvider.Logger.TraceInfo("Using BRE policy {0} {1}.{2} to resolve IBaseMessage.", this.PolicyName, this.MajorRevision, this.MinorRevision);
                    // resolve the context properties
                    MessageContextAccessorResolver resolver = this.Resolve(outMsg);
                    if (resolver.UpdateMessageContext == true)
                    {
                        // update message context
                        resolver.ApplyMessageContextUpdates(pipelineContext, outMsg, true);
                    }

                    pipelineContext.ResourceTracker.AddResource(outMsg);
                    return(outMsg);
                }
                else
                {
                    return(null);
                }
            }
            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);
            }
        }