ResolveInfo.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. public ResolveInfo ()
  18. {
  19. body = new ResolveInfoDC ();
  20. }
  21. public ResolveInfo (Guid clientId, string meshId, int maxAddresses)
  22. : this ()
  23. {
  24. if (clientId == Guid.Empty)
  25. throw new ArgumentException ("Empty Guid");
  26. if (String.IsNullOrEmpty (meshId))
  27. throw new ArgumentNullException ("meshId");
  28. if (maxAddresses <= 0)
  29. throw new ArgumentOutOfRangeException ("maxAddresses must be positive integer");
  30. body.ClientId = clientId;
  31. body.MeshId = meshId;
  32. body.MaxAddresses = maxAddresses;
  33. }
  34. public Guid ClientId {
  35. get { return body.ClientId; }
  36. }
  37. public int MaxAddresses {
  38. get { return body.MaxAddresses; }
  39. }
  40. public string MeshId {
  41. get { return body.MeshId; }
  42. }
  43. public bool HasBody ()
  44. {
  45. return true; // FIXME: I have no idea when it returns false
  46. }
  47. }
  48. [DataContract (Name = "Resolve", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
  49. internal class ResolveInfoDC
  50. {
  51. Guid client_id;
  52. int max_addresses;
  53. string mesh_id;
  54. public ResolveInfoDC ()
  55. {
  56. }
  57. [DataMember]
  58. public Guid ClientId {
  59. get { return client_id; }
  60. set { client_id = value; }
  61. }
  62. [DataMember]
  63. public int MaxAddresses {
  64. get { return max_addresses; }
  65. set { max_addresses = value; }
  66. }
  67. [DataMember]
  68. public string MeshId {
  69. get { return mesh_id; }
  70. set { mesh_id = value; }
  71. }
  72. }
  73. }