public static void TryProbeAndPromoteMessageType(this IBaseMessage message, IPipelineContext pipelineContext)
        {
            var messageType = message.ProbeMessageType(pipelineContext);

            if (pipelineContext.TryGetDocumentSpecByType(messageType, out var docSpec))
            {
                message.Promote(BtsProperties.MessageType, docSpec.DocType);
                message.Promote(BtsProperties.SchemaStrongName, docSpec.DocSpecStrongName);
            }
        }
Пример #2
0
        public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message)
        {
            var messageType = message.ProbeMessageType(pipelineContext);

            if (pipelineContext.TryGetDocumentSpecByType(messageType, out var docSpec))
            {
                message.SetProperty(BizTalkFactoryProperties.MessageType, docSpec.DocType);
            }
            return(message);
        }
Пример #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));
        }