RefreshResponseInfo.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------
  4. namespace System.ServiceModel.PeerResolvers
  5. {
  6. using System.Runtime;
  7. using System.Runtime.Serialization;
  8. using System.ServiceModel;
  9. using System.ServiceModel.Channels;
  10. [MessageContract(IsWrapped = false)]
  11. public class RefreshResponseInfo
  12. {
  13. [DataContract(Name = "RefreshResponseInfo", Namespace = PeerStrings.Namespace)]
  14. class RefreshResponseInfoDC
  15. {
  16. [DataMember(Name = "RegistrationLifetime")]
  17. public TimeSpan RegistrationLifetime;
  18. [DataMember(Name = "Result")]
  19. public RefreshResult Result;
  20. public RefreshResponseInfoDC(TimeSpan registrationLifetime, RefreshResult result)
  21. {
  22. this.RegistrationLifetime = registrationLifetime;
  23. this.Result = result;
  24. }
  25. }
  26. public RefreshResponseInfo() : this(TimeSpan.Zero, RefreshResult.RegistrationNotFound) { }
  27. public RefreshResponseInfo(TimeSpan registrationLifetime, RefreshResult result)
  28. {
  29. this.body = new RefreshResponseInfoDC(registrationLifetime, result);
  30. }
  31. public TimeSpan RegistrationLifetime
  32. {
  33. get { return body.RegistrationLifetime; }
  34. set
  35. {
  36. if (value < TimeSpan.Zero)
  37. {
  38. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
  39. SR.GetString(SR.SFxTimeoutOutOfRange0)));
  40. }
  41. if (TimeoutHelper.IsTooLarge(value))
  42. {
  43. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
  44. SR.GetString(SR.SFxTimeoutOutOfRangeTooBig)));
  45. }
  46. this.body.RegistrationLifetime = value;
  47. }
  48. }
  49. public RefreshResult Result
  50. {
  51. get { return body.Result; }
  52. set { this.body.Result = value; }
  53. }
  54. [MessageBodyMember(Name = "RefreshResponse", Namespace = PeerStrings.Namespace)]
  55. RefreshResponseInfoDC body;
  56. public bool HasBody()
  57. {
  58. return body != null;
  59. }
  60. }
  61. }