早上好, 我有兴趣编写一个知道它正在解码的文档模式的管道组件。我看到有一个函数来获取组件中的模式信息:
IDocumentSpec spec = pContext.GetDocumentSpecByType("name-of-your-schema");
您可以访问在管道中分配的文档架构名称吗?
答案 0 :(得分:5)
您可以从消息的上下文中获取它,如下所示:
private static readonly PropertyBase SchemaStrongNameProperty = new BTS.SchemaStrongName();
private static readonly PropertyBase MessageTypeProperty = new BTS.MessageType();
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
// Get by schema strong name (.NET type)
string schemaStrongName = pInMsg.Context.Read(SchemaStrongNameProperty.Name.Name, SchemaStrongNameProperty.Name.Namespace) as string;
pContext.GetDocumentSpecByName(schemaStrongName);
// Get by message type (XML NS#Root Node)
string messageType = pInMsg.Context.Read(MessageTypeProperty.Name.Name, MessageTypeProperty.Name.Namespace) as string;
pContext.GetDocumentSpecByType(messageType);
// Rest of your pipeline component's code...
}