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();
              }
        }
Beispiel #3
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]);
            }
        }
Beispiel #4
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());
            }
        }