1

我最近一直在做一些 TIBCO 开发,想知道转换到 TIBCO 消息/从 TIBCO 消息转换的最佳方式是什么?

这就是我目前正在做的事情,但我知道必须有更好的方法来做到这一点。但此刻我的大脑被炸了,在 Bing/Google 或 SO 上搜索并没有返回任何有用的信息。

    public static Envelope ParseEnvelope(Message msg)
    {
        try
        {
            var field = msg.GetField("Envelope");
            if(field == null) throw new ArgumentException("msg does not contain Envelope field", "msg");

            var envMsg = field.Value as Message;
            if(envMsg == null) throw new ArgumentException("msg.Envelope field is null or not a Message", "msg");

            var envTypeField = envMsg.GetField("EnvelopeEventId");
            if (envTypeField == null) throw new ArgumentException("msg.Envelope does contain EnvelopeEventId field");

            var envType = envTypeField.Value as String;
            if (envType == null) throw new ArgumentException("msg.Envelope.EnvelopeEventId field is null or not a String", "msg");

            var env = new Envelope(envType);

        }

任何帮助或指针表示赞赏!

现在我正在考虑创建我自己类型的 AutoMapper 来转换 To/From 消息,它会查看 TIBCO 消息根中的特定“字段”以获取它应该转换为的类,然后使用反射(第一次,如果不在缓存中)递归地为该类上的属性树(如果任何属性不是值类型)

4

0 回答 0