public override object DeserializeCommand(string cmd, Type cmdType)
        {
            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.Json.JsonMessageSerializer(mapper);

              using( Stream stream = new MemoryStream(Encoding.UTF8.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.Json.JsonMessageSerializer(mapper);

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

            return new StreamReader(stream).ReadToEnd();
              }
        }
        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];
            }
        }
Пример #4
0
        private static object DeserializeMessage_JSON(string cmd, Type cmdType)
        {
            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.Json.JsonMessageSerializer(mapper);

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

                return(obj[0]);
            }
        }
Пример #5
0
        private static string SerializeMessage_JSON(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.Json.JsonMessageSerializer(mapper);

            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);
            }
        }