ReliableSession.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel
  5. {
  6. using System.ComponentModel;
  7. using System.ServiceModel.Channels;
  8. // The only purpose in life for these classes is so that, on standard bindings, you can say
  9. // binding.ReliableSession.Ordered
  10. // binding.ReliableSession.InactivityTimeout
  11. // binding.ReliableSession.Enabled
  12. // where these properties are "bucketized" all under .ReliableSession, which makes them easier to
  13. // discover/Intellisense
  14. public class ReliableSession
  15. {
  16. ReliableSessionBindingElement element;
  17. public ReliableSession()
  18. {
  19. this.element = new ReliableSessionBindingElement();
  20. }
  21. public ReliableSession(ReliableSessionBindingElement reliableSessionBindingElement)
  22. {
  23. if (reliableSessionBindingElement == null)
  24. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reliableSessionBindingElement");
  25. this.element = reliableSessionBindingElement;
  26. }
  27. [DefaultValue(ReliableSessionDefaults.Ordered)]
  28. public bool Ordered
  29. {
  30. get { return this.element.Ordered; }
  31. set { this.element.Ordered = value; }
  32. }
  33. public TimeSpan InactivityTimeout
  34. {
  35. get { return this.element.InactivityTimeout; }
  36. set
  37. {
  38. if (value <= TimeSpan.Zero)
  39. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
  40. SR.GetString(SR.ValueMustBePositive)));
  41. this.element.InactivityTimeout = value;
  42. }
  43. }
  44. internal void CopySettings(ReliableSession copyFrom)
  45. {
  46. this.Ordered = copyFrom.Ordered;
  47. this.InactivityTimeout = copyFrom.InactivityTimeout;
  48. }
  49. }
  50. public class OptionalReliableSession : ReliableSession
  51. {
  52. bool enabled;
  53. public OptionalReliableSession() : base() { }
  54. public OptionalReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) : base(reliableSessionBindingElement) { }
  55. // We don't include DefaultValue here because this defaults to false, so omitting it would make the XAML somewhat misleading
  56. public bool Enabled
  57. {
  58. get { return this.enabled; }
  59. set
  60. {
  61. this.enabled = value;
  62. }
  63. }
  64. internal void CopySettings(OptionalReliableSession copyFrom)
  65. {
  66. base.CopySettings(copyFrom);
  67. this.Enabled = copyFrom.Enabled;
  68. }
  69. }
  70. }