コード例 #1
0
        public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message)
        {
            if (pipelineContext == null)
            {
                throw new ArgumentNullException(nameof(pipelineContext));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var messageType    = message.ProbeMessageType(pipelineContext);
            var schemaMetadata = pipelineContext.GetSchemaMetadataByType(messageType, false);

            if (schemaMetadata.IsEnvelopeSchema)
            {
                // rewrite empty or partial envelope to prevent disassembler from throwing
                message.BodyPart.WrapOriginalDataStream(
                    originalStream => {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug($"Wrapping message stream in an {nameof(XmlEnvelopeDecodingStream)}.");
                    }
                    return(new XmlEnvelopeDecodingStream(originalStream, schemaMetadata.BodyXPath));
                },
                    pipelineContext.ResourceTracker);
            }
            return(message);
        }
コード例 #2
0
        internal IEnumerable <PropertyExtractor> BuildPropertyExtractorCollection(IPipelineContext pipelineContext, IBaseMessage message)
        {
            var messageType      = message.GetOrProbeMessageType(pipelineContext);
            var schemaMetadata   = pipelineContext.GetSchemaMetadataByType(messageType, false);
            var schemaExtractors = schemaMetadata.Annotations.Extractors;

            return(schemaExtractors.Union(Extractors));
        }
コード例 #3
0
        /// <summary>
        /// Returns the <see cref="ISchemaMetadata"/> associated to the XML schema of messages of a given <see
        /// cref="DocumentSpec"/> type.
        /// </summary>
        /// <param name="pipelineContext">
        /// The pipeline context from which the <see cref="DocumentSpec"/> can be queried.
        /// </param>
        /// <param name="docType">
        /// The <see cref="DocumentSpec"/> type of the messages for which the <see cref="ISchemaMetadata"/> are to be returned.
        /// </param>
        /// <param name="throwOnError">
        /// <c>false</c> to swallow <see cref="COMException"/> and return a <see cref="SchemaMetadata.Unknown"/> should the
        /// document specification not to be found; it will however be logged as a warning. <c>true</c> to let any exception
        /// through.
        /// </param>
        /// <returns>
        /// The <see cref="ISchemaMetadata"/> associated to the XML Schema.
        /// </returns>
        public static ISchemaMetadata GetSchemaMetadataByType(this IPipelineContext pipelineContext, string docType, bool throwOnError)
        {
            if (throwOnError)
            {
                return(pipelineContext.GetSchemaMetadataByType(docType));
            }
            var schemaType = !docType.IsNullOrEmpty() && pipelineContext.TryGetDocumentSpecByType(docType, out var documentSpec)
                                ? Type.GetType(documentSpec.DocSpecStrongName, false)
                                : null;

            return(SchemaMetadata.For(schemaType));
        }