2
0

ResolveInfo.cs 1.8 KB

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