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