(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Messaging / SoapReceivers.cs
blob6853f17918e3369c48b11688894278187dcd75a1
1 //
2 // Microsoft.Web.Services.Messaging.SoapReceivers
3 //
4 // Author: Todd Berman <tberman@gentoo.org>
5 //
6 // (C) 2003 Todd Berman
8 using System;
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)
34 if(uri == null) {
35 throw new ArgumentNullException ("uri");
37 if(receiver == null) {
38 throw new ArgumentNullException ("receiver");
41 lock(SyncRoot) {
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);
49 if(trans != null) {
50 trans.RegisterPort (uri, receiver);
51 } else {
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)
62 if(uri == null) {
63 throw new ArgumentNullException ("uri");
65 if(type == null) {
66 throw new ArgumentNullException ("type");
68 lock(SyncRoot) {
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);
76 if(trans != null) {
77 trans.RegisterPort (uri, type);
78 } else {
79 throw new NotSupportedException ("Transport " + uri.Scheme + " is not supported");
83 _receivers.Add (uri, type);
87 public static void Clear ()
89 lock(SyncRoot) {
90 foreach(ISoapTransport trans in WebServicesConfiguration.MessagingConfiguration.Transports) {
91 trans.UnregisterAll ();
93 _receivers.Clear ();
97 public static bool Contains (Uri to)
99 if(to == null) {
100 throw new ArgumentNullException ("to");
102 bool retVal = false;
103 lock(SyncRoot) {
104 retVal = _receivers.Contains (to);
106 return retVal;
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)
121 if(to == null) {
122 throw new ArgumentNullException ("to");
125 lock(SyncRoot) {
126 if(_receivers.Contains (to) == false) {
127 ISoapTransport trans = WebServicesConfiguration.MessagingConfiguration.GetTransport (to.Scheme);
128 if(trans != null) {
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; }