RegisterResponseInfo.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 RegisterResponseInfo
  12. {
  13. [DataContract(Name = "RegisterResponse", Namespace = PeerStrings.Namespace)]
  14. class RegisterResponseInfoDC
  15. {
  16. [DataMember(Name = "RegistrationLifetime")]
  17. public TimeSpan RegistrationLifetime;
  18. [DataMember(Name = "RegistrationId")]
  19. public Guid RegistrationId;
  20. public RegisterResponseInfoDC() { }
  21. public RegisterResponseInfoDC(Guid registrationId, TimeSpan registrationLifetime)
  22. {
  23. this.RegistrationLifetime = registrationLifetime;
  24. this.RegistrationId = registrationId;
  25. }
  26. }
  27. public RegisterResponseInfo(Guid registrationId, TimeSpan registrationLifetime)
  28. {
  29. body = new RegisterResponseInfoDC(registrationId, registrationLifetime);
  30. }
  31. public RegisterResponseInfo()
  32. {
  33. body = new RegisterResponseInfoDC();
  34. }
  35. public Guid RegistrationId
  36. {
  37. get { return this.body.RegistrationId; }
  38. set { this.body.RegistrationId = value; }
  39. }
  40. public TimeSpan RegistrationLifetime
  41. {
  42. get { return this.body.RegistrationLifetime; }
  43. set
  44. {
  45. if (value < TimeSpan.Zero)
  46. {
  47. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
  48. SR.GetString(SR.SFxTimeoutOutOfRange0)));
  49. }
  50. if (TimeoutHelper.IsTooLarge(value))
  51. {
  52. throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value,
  53. SR.GetString(SR.SFxTimeoutOutOfRangeTooBig)));
  54. }
  55. this.body.RegistrationLifetime = value;
  56. }
  57. }
  58. [MessageBodyMember(Name = "Update", Namespace = PeerStrings.Namespace)]
  59. RegisterResponseInfoDC body;
  60. public bool HasBody()
  61. {
  62. return body != null;
  63. }
  64. }
  65. }