2 // Microsoft.Web.Services.Messaging.SoapReceivers
4 // Author: Todd Berman <tberman@gentoo.org>
6 // (C) 2003 Todd Berman
9 using System
.Collections
;
10 using Microsoft
.Web
.Services
.Configuration
;
12 namespace Microsoft
.Web
.Services
.Messaging
15 public class SoapReceivers
18 private static Hashtable _receivers
= new Hashtable ();
20 private SoapReceivers () { }
22 public static void Add (Uri uri
, SoapReceiver receiver
)
24 Add (uri
, receiver
, false);
27 public static void Add (Uri uri
, Type type
)
29 Add (uri
, type
, false);
32 public static void Add (Uri uri
, SoapReceiver receiver
, bool passive
)
35 throw new ArgumentNullException ("uri");
37 if(receiver
== null) {
38 throw new ArgumentNullException ("receiver");
42 if(_receivers
.Contains (uri
)) {
43 throw new ArgumentException ("An item with this key already exists");
46 if(passive
== false) {
47 ISoapTransport trans
= WebServicesConfiguration
.MessagingConfiguration
.GetTransport (uri
.Scheme
);
50 trans
.RegisterPort (uri
, receiver
);
52 throw new NotSupportedException ("Transport " + uri
.Scheme
+ " not supported.");
56 _receivers
.Add (uri
, receiver
);
60 public static void Add (Uri uri
, Type type
, bool passive
)
63 throw new ArgumentNullException ("uri");
66 throw new ArgumentNullException ("type");
69 if(_receivers
.Contains (uri
)) {
70 throw new ArgumentException ("An item with this key already exists");
73 if(passive
== false) {
74 ISoapTransport trans
= WebServicesConfiguration
.MessagingConfiguration
.GetTransport (uri
.Scheme
);
77 trans
.RegisterPort (uri
, type
);
79 throw new NotSupportedException ("Transport " + uri
.Scheme
+ " is not supported");
83 _receivers
.Add (uri
, type
);
87 public static void Clear ()
90 foreach(ISoapTransport trans
in WebServicesConfiguration
.MessagingConfiguration
.Transports
) {
91 trans
.UnregisterAll ();
97 public static bool Contains (Uri to
)
100 throw new ArgumentNullException ("to");
104 retVal
= _receivers
.Contains (to
);
109 public static IDictionaryEnumerator
GetEnumerator ()
111 return _receivers
.GetEnumerator ();
114 public static object Receiver (Uri to
)
116 return _receivers
[to
];
119 public static void Remove (Uri to
)
122 throw new ArgumentNullException ("to");
126 if(_receivers
.Contains (to
) == false) {
127 ISoapTransport trans
= WebServicesConfiguration
.MessagingConfiguration
.GetTransport (to
.Scheme
);
129 trans
.UnregisterPort (to
);
130 _receivers
.Remove (to
);
136 public static int Count
{
137 get { return _receivers.Values.Count; }
140 public static object SyncRoot
{
141 get { return _receivers.SyncRoot; }