ResolveInfo.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // ResolveInfo.cs
  3. //
  4. // Author:
  5. // Marcos Cobena ([email protected])
  6. //
  7. // Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
  8. //
  9. using System.Runtime.Serialization;
  10. namespace System.ServiceModel.PeerResolvers
  11. {
  12. [MessageContract (IsWrapped = false)]
  13. public class ResolveInfo
  14. {
  15. [MessageBodyMember (Name = "Resolve", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
  16. ResolveInfoDC Body {
  17. get {
  18. if (body == null)
  19. body = new ResolveInfoDC ();
  20. return body;
  21. }
  22. set { body = value; }
  23. }
  24. ResolveInfoDC body;
  25. public ResolveInfo ()
  26. {
  27. }
  28. public ResolveInfo (Guid clientId, string meshId, int maxAddresses)
  29. {
  30. if (clientId == Guid.Empty)
  31. throw new ArgumentException ("Empty Guid");
  32. if (String.IsNullOrEmpty (meshId))
  33. throw new ArgumentNullException ("meshId");
  34. if (maxAddresses <= 0)
  35. throw new ArgumentOutOfRangeException ("maxAddresses must be positive integer");
  36. Body.ClientId = clientId;
  37. Body.MeshId = meshId;
  38. Body.MaxAddresses = maxAddresses;
  39. }
  40. public Guid ClientId {
  41. get { return Body.ClientId; }
  42. }
  43. public int MaxAddresses {
  44. get { return Body.MaxAddresses; }
  45. }
  46. public string MeshId {
  47. get { return Body.MeshId; }
  48. }
  49. public bool HasBody ()
  50. {
  51. return true; // FIXME: I have no idea when it returns false
  52. }
  53. }
  54. [DataContract (Name = "Resolve", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
  55. internal class ResolveInfoDC
  56. {
  57. Guid client_id;
  58. int max_addresses;
  59. string mesh_id;
  60. public ResolveInfoDC ()
  61. {
  62. }
  63. [DataMember]
  64. public Guid ClientId {
  65. get { return client_id; }
  66. set { client_id = value; }
  67. }
  68. [DataMember]
  69. public int MaxAddresses {
  70. get { return max_addresses; }
  71. set { max_addresses = value; }
  72. }
  73. [DataMember]
  74. public string MeshId {
  75. get { return mesh_id; }
  76. set { mesh_id = value; }
  77. }
  78. }
  79. }