internal static String ContentTypeOrDefault(this IBasicProperties source, String @default = "application/json") { const String key = "Content-Type"; if (!String.IsNullOrEmpty(source.ContentType)) { return(source.ContentType); } if (source.Headers == null || !source.Headers.ContainsKey(key)) { return(@default); } var bytes = (Byte[])source.Headers[key]; return(bytes.Length > 0 ? source.CreateEncoding().GetString(bytes) : @default); }
protected Byte[] BuildBody(IMessage source, IBasicProperties properties) { return(properties.CreateEncoding() .GetBytes(properties.CreateSerializer(Configuration.SerializationConfiguration) .Serialize(source.Content))); }