//
using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
namespace System.Runtime.Remoting.Channels
{
+ [System.Runtime.InteropServices.ComVisible (true)]
public sealed class ChannelServices
{
private static ArrayList registeredChannels = new ArrayList ();
}
else {
foreach (object data in channelDataArray) {
- IMessageSink sink = sender.CreateMessageSink (url, data, out objectUri);
+ IMessageSink sink;
+
+ if (data is IChannelDataStore) {
+ // Don't provide the url in this case, since some channels won't
+ // check the channelData parameter if the url is not null.
+ sink = sender.CreateMessageSink (null, data, out objectUri);
+ } else {
+ sink = sender.CreateMessageSink (url, data, out objectUri);
+ }
if (sink != null) return sink;
}
}
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;
+ var list = new List<IChannel> ();
+
+ for (int i = 0; i < registeredChannels.Count; i++) {
+ IChannel ch = (IChannel) registeredChannels[i];
+ if (ch is CrossAppDomainChannel) continue;
+ list.Add (ch);
+ }
+
+ return list.ToArray ();
}
}
}
ClientIdentity ident = (ClientIdentity) RemotingServices.GetRealProxy (obj).ObjectIdentity;
IMessageSink sink = ident.ChannelSink;
- ArrayList dics = new ArrayList ();
+ var dics = new List<IDictionary> ();
while (sink != null && !(sink is IClientChannelSink))
sink = sink.NextSink;
csink = csink.NextChannelSink;
}
- IDictionary[] adics = (IDictionary[]) dics.ToArray (typeof(IDictionary[]));
+ IDictionary[] adics = dics.ToArray ();
return new AggregateDictionary (adics);
}
string uri = RemotingServices.GetObjectUri (obj);
if (uri == null) return new string [0];
- ArrayList list = new ArrayList ();
+ var list = new List<string> ();
lock (registeredChannels.SyncRoot)
{
}
}
- return (string[]) list.ToArray (typeof(string));
+ return list.ToArray ();
}
+ [Obsolete ("Use RegisterChannel(IChannel,Boolean)")]
public static void RegisterChannel (IChannel chnl)
{
+ RegisterChannel (chnl, false);
+ }
+
+ public static void RegisterChannel (IChannel chnl, bool ensureSecurity)
+ {
+ if (chnl == null)
+ throw new ArgumentNullException ("chnl");
+
+ if (ensureSecurity) {
+ ISecurableChannel securable = chnl as ISecurableChannel;
+ if (securable == null)
+ throw new RemotingException (String.Format ("Channel {0} is not securable while ensureSecurity is specified as true", chnl.ChannelName));
+ securable.IsSecured = true;
+ }
+
// Put the channel in the correct place according to its priority.
// Since there are not many channels, a linear search is ok.
if (pos != -1) registeredChannels.Insert (pos, chnl);
else registeredChannels.Add (chnl);
-
+
IChannelReceiver receiver = chnl as IChannelReceiver;
- if (receiver != null) receiver.StartListening (null);
+ if (receiver != null && oldStartModeTypes.Contains (chnl.GetType().ToString ()))
+ receiver.StartListening (null);
}
}
return null;
}
-#if NET_1_1
if (RemotingConfiguration.CustomErrorsEnabled (IsLocalCall (msg)))
replySink = new ExceptionFilterSink (msg, replySink);
-#endif
return _crossContextSink.AsyncProcessMessage (msg, replySink);
}
internal static IMessage CheckReturnMessage (IMessage callMsg, IMessage retMsg)
{
-#if NET_1_1
IMethodReturnMessage ret = retMsg as IMethodReturnMessage;
if (ret != null && ret.Exception != null)
{
retMsg = new MethodResponse (ex, (IMethodCallMessage)callMsg);
}
}
-#endif
return retMsg;
}
internal static object [] GetCurrentChannelInfo ()
{
- ArrayList list = new ArrayList ();
+ var list = new List<object> ();
lock (registeredChannels.SyncRoot)
{
}
}
- return list.ToArray ();
+ return list.ToArray ();
}
+
+ // Back compatibility fix. StartListener will be called for the types listed here
+ static IList oldStartModeTypes = new string[] {
+ "Novell.Zenworks.Zmd.Public.UnixServerChannel",
+ "Novell.Zenworks.Zmd.Public.UnixChannel"
+ };
}
internal class ExceptionFilterSink: IMessageSink