PollEvents.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. namespace NetMQ
  3. {
  4. /// <summary>
  5. /// This flags enum-type is simply an indication of the direction of the poll-event,
  6. /// and can be None, PollIn, PollOut, or PollError.
  7. /// </summary>
  8. [Flags]
  9. public enum PollEvents
  10. {
  11. /// <summary>
  12. /// No events
  13. /// </summary>
  14. None = 0x0,
  15. /// <summary>
  16. /// Check for incoming
  17. /// </summary>
  18. PollIn = 0x1,
  19. /// <summary>
  20. /// Check if ready for outgoing
  21. /// </summary>
  22. PollOut = 0x2,
  23. /// <summary>
  24. /// Check if error is ready to be read
  25. /// </summary>
  26. PollError = 0x4
  27. }
  28. /// <summary>
  29. /// Extension methods for the <see cref="PollEvents"/> enum.
  30. /// </summary>
  31. public static class PollEventsExtensions
  32. {
  33. /// <summary>Test whether <paramref name="pollEvents"/> has the <see cref="PollEvents.PollIn"/> flag set.</summary>
  34. public static bool HasIn(this PollEvents pollEvents)
  35. {
  36. return (pollEvents & PollEvents.PollIn) == PollEvents.PollIn;
  37. }
  38. /// <summary>Test whether <paramref name="pollEvents"/> has the <see cref="PollEvents.PollOut"/> flag set.</summary>
  39. public static bool HasOut(this PollEvents pollEvents)
  40. {
  41. return (pollEvents & PollEvents.PollOut) == PollEvents.PollOut;
  42. }
  43. /// <summary>Test whether <paramref name="pollEvents"/> has the <see cref="PollEvents.PollError"/> flag set.</summary>
  44. public static bool HasError(this PollEvents pollEvents)
  45. {
  46. return (pollEvents & PollEvents.PollError) == PollEvents.PollError;
  47. }
  48. }
  49. }