/// <summary> /// Determines whether the message body can be compressed based on the specified header. /// </summary> /// <param name="header">The header.</param> /// <param name="checkMessageFlags">A flag to check the message flags provided in the header.</param> /// <returns><c>true</c> if the message body can be comressed; otherwise, <c>false</c>.</returns> public static bool CanCompressMessageBody(this IMessageHeader header, bool checkMessageFlags = false) { // Never compress RequestSession or OpenSession in Core protocol if (header.Protocol == 0 && (header.IsRequestSession() || header.IsOpenSession())) { return(false); } // Don't compress Acknowledge or ProtocolException when sent by any protocol if (header.IsAcknowledge() || header.IsProtocolException()) { return(false); } // Do the message flags indicate the body was compressed return(!checkMessageFlags || header.HasFlag(MessageFlags.Compressed)); }
/// <summary> /// Checks if an acknowledge message is requested. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if an acknowledge message is requested; <c>false</c> otherwise.</returns> public static bool IsAcknowledgeRequested(this IMessageHeader header) { return(header.HasFlag(MessageFlags.Acknowledge)); }
/// <summary> /// Checks if the message body is compressed. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if the message body is compressed; <c>false</c> otherwise.</returns> public static bool IsBodyCompressed(this IMessageHeader header) { return(header.HasFlag(MessageFlags.Compressed)); }
/// <summary> /// Checks if there is no data. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if there is no data; <c>false</c> otherwise.</returns> public static bool IsNoData(this IMessageHeader header) { return(header.HasFlag(MessageFlags.NoData)); }
/// <summary> /// Checks if this header is the final part of a multi-part message. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if the header is the final part of a multi-part message; <c>false</c> otherwise.</returns> public static bool IsFinalPart(this IMessageHeader header) { return(header.HasFlag(MessageFlags.FinalPart)); }
/// <summary> /// Checks if this header is part of a multi-part message. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if the header is part of a multi-part message; <c>false</c> otherwise.</returns> public static bool IsMultiPart(this IMessageHeader header) { return(header.HasFlag(MessageFlags.MultiPart)); }
/// <summary> /// Checks if the message has a header extension. /// </summary> /// <param name="header">The message header.</param> /// <returns><c>true</c> if the message has a header extension; <c>false</c> otherwise.</returns> public static bool HasHeaderExtension(this IMessageHeader header) { return(header.HasFlag(MessageFlags.HasHeaderExtension)); }