2
0

MessageVersion.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // System.ServiceModel.MessageVersion.cs
  3. //
  4. // Author: Duncan Mak ([email protected])
  5. //
  6. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.ServiceModel;
  29. namespace System.ServiceModel.Channels {
  30. public sealed class MessageVersion
  31. {
  32. EnvelopeVersion envelope;
  33. AddressingVersion addressing;
  34. MessageVersion (EnvelopeVersion envelope, AddressingVersion addressing)
  35. {
  36. this.envelope = envelope;
  37. this.addressing = addressing;
  38. }
  39. public static MessageVersion CreateVersion (EnvelopeVersion envelope_version)
  40. {
  41. return CreateVersion (envelope_version,
  42. AddressingVersion.WSAddressing10);
  43. }
  44. public static MessageVersion CreateVersion (EnvelopeVersion envelope_version,
  45. AddressingVersion addressing_version)
  46. {
  47. return new MessageVersion (envelope_version, addressing_version);
  48. }
  49. public override bool Equals (object value)
  50. {
  51. MessageVersion other = value as MessageVersion;
  52. if (other == null)
  53. return false;
  54. return (other.Addressing == this.Addressing) && (other.Envelope == this.Envelope);
  55. }
  56. public override int GetHashCode ()
  57. {
  58. return addressing.GetHashCode () + envelope.GetHashCode ();
  59. }
  60. public override string ToString ()
  61. {
  62. return envelope.ToString () + " " + addressing.ToString ();
  63. }
  64. public AddressingVersion Addressing {
  65. get { return addressing; }
  66. }
  67. public static MessageVersion Default {
  68. get { return CreateVersion (EnvelopeVersion.Soap12); }
  69. }
  70. public EnvelopeVersion Envelope {
  71. get { return envelope; }
  72. }
  73. public static MessageVersion None {
  74. get { return CreateVersion (EnvelopeVersion.None, AddressingVersion.None); }
  75. }
  76. public static MessageVersion Soap11 {
  77. get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.None); }
  78. }
  79. public static MessageVersion Soap12 {
  80. get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.None); }
  81. }
  82. public static MessageVersion Soap11WSAddressing10 {
  83. get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10); }
  84. }
  85. public static MessageVersion Soap11WSAddressingAugust2004 {
  86. get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressingAugust2004); }
  87. }
  88. public static MessageVersion Soap12WSAddressing10 {
  89. get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10); }
  90. }
  91. public static MessageVersion Soap12WSAddressingAugust2004 {
  92. get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressingAugust2004); }
  93. }
  94. }
  95. }