ValidationUtility.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. namespace Experimental.System.Messaging
  2. {
  3. internal static class ValidationUtility
  4. {
  5. public static bool ValidateCryptographicProviderType(CryptographicProviderType value)
  6. {
  7. return (value >= CryptographicProviderType.None) && (value <= CryptographicProviderType.SttIss);
  8. }
  9. public static bool ValidateEncryptionAlgorithm(EncryptionAlgorithm value)
  10. {
  11. //
  12. // note that EncryptionAlgorithm has disjoined values
  13. //
  14. return (value == EncryptionAlgorithm.None) ||
  15. (value == EncryptionAlgorithm.Rc2) ||
  16. (value == EncryptionAlgorithm.Rc4);
  17. }
  18. public static bool ValidateEncryptionRequired(EncryptionRequired value)
  19. {
  20. return (value >= EncryptionRequired.None) && (value <= EncryptionRequired.Body);
  21. }
  22. public static bool ValidateHashAlgorithm(HashAlgorithm value)
  23. {
  24. //
  25. // note that HashAlgorithm has disjoined values
  26. //
  27. return (value == HashAlgorithm.None) ||
  28. (value == HashAlgorithm.Md2) ||
  29. (value == HashAlgorithm.Md4) ||
  30. (value == HashAlgorithm.Md5) ||
  31. (value == HashAlgorithm.Sha) ||
  32. (value == HashAlgorithm.Sha256) ||
  33. (value == HashAlgorithm.Sha384) ||
  34. (value == HashAlgorithm.Sha512) ||
  35. (value == HashAlgorithm.Mac);
  36. }
  37. public static bool ValidateMessageLookupAction(MessageLookupAction value)
  38. {
  39. //
  40. // note that MessageLookupAction has disjoined values
  41. //
  42. return (value == MessageLookupAction.Current) ||
  43. (value == MessageLookupAction.Next) ||
  44. (value == MessageLookupAction.Previous) ||
  45. (value == MessageLookupAction.First) ||
  46. (value == MessageLookupAction.Last);
  47. }
  48. public static bool ValidateMessagePriority(MessagePriority value)
  49. {
  50. return (value >= MessagePriority.Lowest) && (value <= MessagePriority.Highest);
  51. }
  52. public static bool ValidateMessageQueueTransactionType(MessageQueueTransactionType value)
  53. {
  54. //
  55. // note that MessageQueueTransactionType has disjoined values
  56. //
  57. return (value == MessageQueueTransactionType.None) ||
  58. (value == MessageQueueTransactionType.Automatic) ||
  59. (value == MessageQueueTransactionType.Single);
  60. }
  61. public static bool ValidateQueueAccessMode(QueueAccessMode value)
  62. {
  63. //
  64. // note that QueueAccessMode has disjoined values
  65. //
  66. return (value == QueueAccessMode.Send) ||
  67. (value == QueueAccessMode.Peek) ||
  68. (value == QueueAccessMode.Receive) ||
  69. (value == QueueAccessMode.PeekAndAdmin) ||
  70. (value == QueueAccessMode.ReceiveAndAdmin) ||
  71. (value == QueueAccessMode.SendAndReceive);
  72. }
  73. public static bool ValidateTrusteeType(TrusteeType trustee)
  74. {
  75. return (trustee >= TrusteeType.Unknown) && (trustee <= TrusteeType.Computer);
  76. }
  77. } //class ValidationUtility
  78. }