public override object DeserializeCommand(string cmd)
        {
            var types = new List<Type> { cmd.GetType() };

              var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();
              mapper.Initialize(types);

              var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);
              serializr.Initialize(types);

              using( Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(cmd)) ) {
            var obj = serializr.Deserialize(stream);

            return obj[0];
              }
        }
        private static object DeserializeMessage_XML(string cmd, Type cmdType)
        {
            var types = new List<Type> { cmdType };

            var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();
            mapper.Initialize(types);

            var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);
            serializr.Initialize(types);

            using( Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(cmd)) ) {
              var obj = serializr.Deserialize(stream);

              return obj[0];
            }
        }
        public override string SerializeCommand(object cmd)
        {
            var types = new List<Type> { cmd.GetType() };

              var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();
              mapper.Initialize(types);

              var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);
              serializr.Initialize(types);

              using( Stream stream = new MemoryStream() ) {
            serializr.Serialize(new[] { cmd }, stream);
            stream.Position = 0;

            return new StreamReader(stream).ReadToEnd();
              }
        }
Пример #4
0
        private static object DeserializeMessage_XML(string cmd, Type cmdType)
        {
            var types = new List <Type> {
                cmdType
            };

            var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();

            mapper.Initialize(types);

            var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);

            serializr.Initialize(types);

            using (Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(cmd))) {
                var obj = serializr.Deserialize(stream);

                return(obj[0]);
            }
        }
Пример #5
0
        private static string SerializeMessage_XML(object cmd)
        {
            var types = new List <Type> {
                cmd.GetType()
            };

            var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();

            mapper.Initialize(types);

            var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);

            serializr.Initialize(types);

            using (Stream stream = new MemoryStream()) {
                serializr.Serialize(new[] { cmd }, stream);
                stream.Position = 0;

                return(new StreamReader(stream).ReadToEnd());
            }
        }
        public override object DeserializeCommand(string cmd, Type cmdType)
        {
            try {
            var types = new List<Type> { cmdType };

            var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();
            mapper.Initialize(types);

            var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);
            serializr.Initialize(types);

            using( Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(cmd)) ) {
              var obj = serializr.Deserialize(stream);

              return obj[0];
            }
              } catch( Exception e ) {
            OnError("Failed to parse command string as XML", e);
            return null;
              }
        }
        public override object DeserializeCommand(string cmd, Type cmdType)
        {
            try {
                var types = new List <Type> {
                    cmdType
                };

                var mapper = new global::NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper();
                mapper.Initialize(types);

                var serializr = new global::NServiceBus.Serializers.XML.XmlMessageSerializer(mapper);
                serializr.Initialize(types);

                using (Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(cmd))) {
                    var obj = serializr.Deserialize(stream);

                    return(obj[0]);
                }
            } catch (Exception e) {
                OnError("Failed to parse command string as XML", e);
                return(null);
            }
        }