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);
        }
Пример #2
0
 protected Byte[] BuildBody(IMessage source, IBasicProperties properties)
 {
     return(properties.CreateEncoding()
            .GetBytes(properties.CreateSerializer(Configuration.SerializationConfiguration)
                      .Serialize(source.Content)));
 }