public void GetTypeName_ReturnTypeName_ThatIsRecoverable_GenericClassMultiple() { var result = MessageTypeConverters.GetTypeName(typeof(GenericTestClass <string, IDictionary <object, DateTime>, int>)); var resultType = Type.GetType(result); Assert.True(typeof(GenericTestClass <string, IDictionary <object, DateTime>, int>).Equals(resultType)); }
public Task ExecuteAsync(OutgoingPipelineContext ctx, Func <Task> next) { var message = ctx.Load <Messages.Message>(); message.Headers[MessageHeaders.EventType] = MessageTypeConverters.GetTypeName(message.Body.GetType()); return(FuncInvoker.Invoke(next)); }
public void GetTypeName_ReturnTypeName_ThatIsRecoverable_GenericClass() { var result = MessageTypeConverters.GetTypeName(typeof(GenericTestClass <string>)); var resultType = Type.GetType(result); Assert.True(typeof(GenericTestClass <string>).Equals(resultType)); }
public void GetTypeName_ReturnTypeName_ThatIsRecoverable_SimpleClass() { var result = MessageTypeConverters.GetTypeName(typeof(TestClass)); var resultType = Type.GetType(result); Assert.True(typeof(TestClass).Equals(resultType)); }
private Message Deserialize(TransportMessage message) { var messageTypeName = message.Headers[MessageHeaders.EventType]; var messageType = MessageTypeConverters.GetNameType(messageTypeName); var bodyString = DefaultEncoding.GetString(message.Body); return(new Message(JsonConvert.DeserializeObject(bodyString, messageType), new Dictionary <string, string>(message.Headers))); }
public void GetNameType_ReturnProperType_GenericClassMultiple() { var typeString = "KDR.Unit.Tests.Messages.MessageTypeConvertersTests+GenericTestClass`3[[System.String, System.Private.CoreLib], [System.Collections.Generic.IDictionary`2[[System.Object, System.Private.CoreLib], [System.DateTime, System.Private.CoreLib]], System.Private.CoreLib], [System.Int32, System.Private.CoreLib]], KDR.Unit.Tests"; var resultType = MessageTypeConverters.GetNameType(typeString); var result = MessageTypeConverters.GetTypeName(resultType); Assert.AreEqual(typeString, result); }
public void GetNameType_ReturnProperType_GenericClass() { var typeString = "KDR.Unit.Tests.Messages.MessageTypeConvertersTests+GenericTestClass`1[[System.String, System.Private.CoreLib]], KDR.Unit.Tests"; var resultType = MessageTypeConverters.GetNameType(typeString); var result = MessageTypeConverters.GetTypeName(resultType); Assert.AreEqual(typeString, result); }
public void GetNameType_ReturnProperType_SimpleClass() { var typeString = "KDR.Unit.Tests.Messages.MessageTypeConvertersTests+TestClass, KDR.Unit.Tests"; var resultType = MessageTypeConverters.GetNameType(typeString); var result = MessageTypeConverters.GetTypeName(resultType); Assert.AreEqual(typeString, result); }
private Message Deserialize(TransportMessage message) { var messageTypeName = message.Headers[MessageHeaders.EventType]; var messageType = MessageTypeConverters.GetNameType(messageTypeName); var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(messageType); using (var memoryStream = new MemoryStream(message.Body)) { return(new Message(dataContractSerializer.ReadObject(memoryStream), new Dictionary <string, string>(message.Headers))); } }
private TransportMessage Serialize(Message message) { var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(message.Body.GetType()); var headers = new Dictionary <string, string>(message.Headers) { [MessageHeaders.ContentType] = ContentTypes.XmlContentType, [MessageHeaders.EventType] = MessageTypeConverters.GetTypeName(message.Body.GetType()) }; using (var memoryStream = new MemoryStream()) { dataContractSerializer.WriteObject(memoryStream, message.Body); return(new TransportMessage(headers, memoryStream.ToArray())); } }
private TransportMessage Serialize(Message message) { var body = JsonConvert.SerializeObject(message.Body, DefaultSettings); var bodyBytes = DefaultEncoding.GetBytes(body); //TODO: Powinno zostać wyciągnięte var headers = new Dictionary <string, string>(message.Headers) { [MessageHeaders.ContentType] = ContentTypes.JsonUtf8ContentType, [MessageHeaders.EventType] = MessageTypeConverters.GetTypeName(message.Body.GetType()) }; return(new TransportMessage(headers, bodyBytes)); }