start populating the new System.Web.Configuration_2.0 dir
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Channels / ChannelServices.cs
index b8c4e2af3f3b4beb1f32b5fe98272a31084d9e6c..e2ab7935e9c8c14070052e930f16ade2fa575782 100644 (file)
@@ -8,6 +8,29 @@
 // 2002 (C) Copyright, Ximian, Inc.
 //
 
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System.Collections;
 using System.Reflection;
 using System.Runtime.Remoting;
@@ -85,6 +108,7 @@ namespace System.Runtime.Remoting.Channels
                                }
                                
                                // Not found. Try now creation delayed channels
+                               RemotingConfiguration.LoadDefaultDelayedChannels ();
                                foreach (IChannelSender sender in delayedClientChannels) 
                                {
                                        IMessageSink sink = CreateClientChannelSinkChain (sender, url, channelDataArray, out objectUri);
@@ -120,12 +144,15 @@ namespace System.Runtime.Remoting.Channels
                        get {
                                lock (registeredChannels.SyncRoot)
                                {
-                                       IChannel[] channels = new IChannel[registeredChannels.Count];
-       
-                                       for (int i = 0; i < registeredChannels.Count; i++)
-                                               channels[i] = (IChannel) registeredChannels[i];
-       
-                                       return channels;
+                                       ArrayList list = new ArrayList ();
+                                       
+                                       for (int i = 0; i < registeredChannels.Count; i++) {
+                                               IChannel ch = (IChannel) registeredChannels[i];
+                                               if (ch is CrossAppDomainChannel) continue;
+                                               list.Add (ch);
+                                       }
+
+                                       return (IChannel[]) list.ToArray (typeof(IChannel));
                                }
                        }
                }
@@ -230,7 +257,7 @@ namespace System.Runtime.Remoting.Channels
                                {
                                        IChannel regc = (IChannel) registeredChannels[n];
                                        
-                                       if (regc.ChannelName == chnl.ChannelName)
+                                       if (regc.ChannelName == chnl.ChannelName && chnl.ChannelName != "")
                                                throw new RemotingException ("Channel " + regc.ChannelName + " already registered");
                                                
                                        if (regc.ChannelPriority < chnl.ChannelPriority && pos==-1)
@@ -404,14 +431,19 @@ namespace System.Runtime.Remoting.Channels
                                
                        lock (registeredChannels.SyncRoot)
                        {
-                               if (!registeredChannels.Contains ((object) chnl))
-                                       throw new RemotingException ();
-       
-                               registeredChannels.Remove ((object) chnl);
+                               for (int n=0; n<registeredChannels.Count; n++) 
+                               {
+                                       if (registeredChannels [n] == (object)chnl) {
+                                               registeredChannels.RemoveAt (n);
+                                               IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
+                                               if(chnlReceiver != null)
+                                                       chnlReceiver.StopListening(null);
+                                               return;
+                                       }
+                               }
+                               
+                               throw new RemotingException ("Channel not registered");
        
-                               IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
-                               if(chnlReceiver != null)
-                                       chnlReceiver.StopListening(null);
                        }
                }
 
@@ -436,7 +468,7 @@ namespace System.Runtime.Remoting.Channels
                }
        }
        
-       public class ExceptionFilterSink: IMessageSink
+       internal class ExceptionFilterSink: IMessageSink
        {
                IMessageSink _next;
                IMessage _call;