ce36fbf5d658e769e0f3c4cbd55fd4dee0723f6b
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Channels / ChannelServices.cs
1 //
2 // System.Runtime.Remoting.Channels.ChannelServices.cs
3 //
4 // Author: Rodrigo Moya (rodrigo@ximian.com)
5 //         Dietmar Maurer (dietmar@ximian.com)
6 //
7 // 2002 (C) Copyright, Ximian, Inc.
8 //
9
10 using System.Collections;
11 using System.Runtime.Remoting.Messaging;
12
13 namespace System.Runtime.Remoting.Channels
14 {
15         internal class ChannelInfoStore : IChannelInfo
16         {
17                 object [] data = null;
18
19                 public ChannelInfoStore ()
20                 {
21                         this.data = ChannelServices.GetCurrentChannelInfo ();
22                 }
23                 
24                 public object[] ChannelData {
25
26                         get {
27                                 return data;
28                         }
29                         
30                         set {
31                                 data = value;
32                         }
33                 }
34         }
35         
36         public sealed class ChannelServices
37         {
38                 private static ArrayList registeredChannels = new ArrayList ();
39                 
40                 private ChannelServices ()
41                 {
42                 }
43                 
44                 public static IChannel[] RegisteredChannels
45                 {
46                         get {
47                                 IChannel[] channels = new IChannel[registeredChannels.Count];
48
49                                 for (int i = 0; i < registeredChannels.Count; i++)
50                                         channels[i] = (IChannel) registeredChannels[i];
51
52                                 return channels;
53                         }
54                 }
55
56                 [MonoTODO]
57                 public static IMessageCtrl AsyncDispatchMessage (IMessage msg,
58                                                                  IMessageSink replySink)
59                 {
60                         throw new NotImplementedException ();
61                 }
62
63                 public static IServerChannelSink CreateServerChannelSinkChain (
64                         IServerChannelSinkProvider provider,
65                         IChannelReceiver channel)
66                 {
67                         IServerChannelSinkProvider tmp = provider;
68                         while (tmp.Next != null) tmp = tmp.Next;
69                         tmp.Next = new ServerDispatchSinkProvider ();
70
71                         return  provider.CreateSink (channel);
72                 }
73
74                 [MonoTODO]
75                 public static ServerProcessing DispatchMessage (
76                         IServerChannelSinkStack sinkStack,
77                         IMessage msg,
78                         out IMessage replyMsg)
79                 {
80                         throw new NotImplementedException ();
81                 }
82
83                 [MonoTODO]
84                 public static IChannel GetChannel (string name)
85                 {
86                         throw new NotImplementedException ();
87                 }
88
89                 [MonoTODO]
90                 public static IDictionary GetChannelSinkProperties (object obj)
91                 {
92                         throw new NotImplementedException ();
93                 }
94
95                 [MonoTODO]
96                 public static string[] GetUrlsForObject (MarshalByRefObject obj)
97                 {
98                         throw new NotImplementedException ();
99                 }
100
101                 public static void RegisterChannel (IChannel chnl)
102                 {
103                         // fixme: sort it by priority
104                         registeredChannels.Add ((object) chnl);
105                 }
106
107                 [MonoTODO]
108                 public static IMessage SyncDispatchMessage (IMessage msg)
109                 {
110                         throw new NotImplementedException ();
111                 }
112
113                 public static void UnregisterChannel (IChannel chnl)
114                 {
115                         if (chnl == null)
116                                 throw new ArgumentNullException ();
117                         if (!registeredChannels.Contains ((object) chnl))
118                                 throw new RemotingException ();
119
120                         registeredChannels.Remove ((object) chnl);
121                 }
122
123                 internal static object [] GetCurrentChannelInfo ()
124                 {
125                         ArrayList list = new ArrayList ();
126                         
127                         foreach (object chnl_obj in registeredChannels) {
128                                 IChannelReceiver chnl = chnl_obj as IChannelReceiver;
129                         
130                                 if (chnl != null) {
131                                         object chnl_data = chnl.ChannelData;
132                                         if (chnl_data != null)
133                                                 list.Add (chnl_data);
134                                 }
135                         }
136
137                         return  list.ToArray ();
138                 }
139         }
140 }