2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel / NetPeerTcpBinding.cs
1 //
2 // NetPeerTcpBinding.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //      Marcos Cobena (marcoscobena@gmail.com)
7 //
8 // Copyright (C) 2005 Novell, Inc.  http://www.novell.com
9 // Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 using System;
31 using System.Collections.Generic;
32 using System.Net;
33 using System.Net.Security;
34 using System.ServiceModel.Channels;
35 using System.ServiceModel.Description;
36 using System.ServiceModel.PeerResolvers;
37 using System.Text;
38 using System.Xml;
39
40 namespace System.ServiceModel
41 {
42         public class NetPeerTcpBinding : Binding, IBindingRuntimePreferences
43         {
44                 // We don't support PNRP
45                 public static bool IsPnrpAvailable {
46                         get { return false; }
47                 }
48
49                 XmlDictionaryReaderQuotas reader_quotas = new XmlDictionaryReaderQuotas ();
50                 PeerResolverSettings resolver = new PeerResolverSettings ();
51                 PeerSecuritySettings security = new PeerSecuritySettings ();
52                 PeerTransportBindingElement transport = new PeerTransportBindingElement ();
53
54                 public NetPeerTcpBinding ()
55                 {
56                 }
57
58                 [MonoTODO]
59                 public NetPeerTcpBinding (string configurationName)
60                 {
61                         throw new NotImplementedException ();
62                 }
63
64                 [MonoTODO]
65                 public IPAddress ListenIPAddress {
66                         get { return transport.ListenIPAddress; }
67                         set { transport.ListenIPAddress = value; }
68                 }
69
70                 [MonoTODO]
71                 public new long MaxBufferPoolSize {
72                         get { return transport.MaxBufferPoolSize; }
73                         set { transport.MaxBufferPoolSize = value; }
74                 }
75
76                 [MonoTODO]
77                 public long MaxReceivedMessageSize {
78                         get { return transport.MaxReceivedMessageSize; }
79                         set { transport.MaxReceivedMessageSize = value; }
80                 }
81
82                 public int Port {
83                         get { return transport.Port; }
84                         set { transport.Port = value; }
85                 }
86
87                 public PeerResolverSettings Resolver {
88                         get { return resolver; }
89                 }
90
91                 public XmlDictionaryReaderQuotas ReaderQuotas {
92                         get { return reader_quotas; }
93                         set {
94                                 if (value == null)
95                                         throw new ArgumentNullException ("value");
96                                 reader_quotas = value;
97                         }
98                 }
99
100                 public override string Scheme {
101                         get { return "net.p2p"; }
102                 }
103                 
104                 public PeerSecuritySettings Security {
105                         get { return security; }
106                 }
107
108                 public EnvelopeVersion EnvelopeVersion {
109                         get { return EnvelopeVersion.Soap12; }
110                 }
111
112                 public override BindingElementCollection
113                         CreateBindingElements ()
114                 {
115                         var mbe = new BinaryMessageEncodingBindingElement ();
116                         if (ReaderQuotas != null)
117                                 ReaderQuotas.CopyTo (mbe.ReaderQuotas);
118
119                         var prbe = Resolver.CreateBinding ();
120
121                         return new BindingElementCollection (new BindingElement [] { mbe, prbe, transport.Clone () });
122                 }
123
124                 // explicit interface implementations
125
126                 bool IBindingRuntimePreferences.ReceiveSynchronously {
127                         get { return false; }
128                 }
129         }
130 }