Merge pull request #225 from mistoll/master
[mono.git] / mcs / class / System.Runtime.Remoting / System.Runtime.Remoting.Channels.Ipc / IpcServerChannel.cs
1 //\r
2 // System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.cs\r
3 //\r
4 // Author: Robert Jordan (robertj@gmx.net)\r
5 //\r
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)\r
7 //\r
8 //\r
9 // Permission is hereby granted, free of charge, to any person obtaining\r
10 // a copy of this software and associated documentation files (the\r
11 // "Software"), to deal in the Software without restriction, including\r
12 // without limitation the rights to use, copy, modify, merge, publish,\r
13 // distribute, sublicense, and/or sell copies of the Software, and to\r
14 // permit persons to whom the Software is furnished to do so, subject to\r
15 // the following conditions:\r
16 // \r
17 // The above copyright notice and this permission notice shall be\r
18 // included in all copies or substantial portions of the Software.\r
19 // \r
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
27 //\r
28 \r
29 #if NET_2_0\r
30 \r
31 using System;\r
32 using System.Collections;\r
33 using System.Runtime.Remoting;\r
34 \r
35 using Unix  = System.Runtime.Remoting.Channels.Ipc.Unix;\r
36 using Win32 = System.Runtime.Remoting.Channels.Ipc.Win32;\r
37 \r
38 namespace System.Runtime.Remoting.Channels.Ipc\r
39 {\r
40         public class IpcServerChannel : IChannelReceiver, IChannel\r
41         {\r
42                 IChannelReceiver _innerChannel;\r
43                 string _portName;\r
44 \r
45                 public IpcServerChannel (string portName)\r
46                 {\r
47                         _portName = portName;\r
48 \r
49                         if (IpcChannel.IsUnix)\r
50                                 _innerChannel = new Unix.IpcServerChannel (portName);\r
51                         else\r
52                                 _innerChannel = new Win32.IpcServerChannel (portName);\r
53                 }\r
54 \r
55                 public IpcServerChannel (IDictionary properties,\r
56                                          IServerChannelSinkProvider  sinkProvider)\r
57                 {\r
58                         if (properties != null)\r
59                                 _portName = properties ["portName"] as string;\r
60 \r
61                         if (IpcChannel.IsUnix)\r
62                                 _innerChannel = new Unix.IpcServerChannel (properties,  sinkProvider);\r
63                         else\r
64                                 _innerChannel = new Win32.IpcServerChannel (properties, sinkProvider);\r
65                 }\r
66 \r
67                 public IpcServerChannel (string name, string portName,\r
68                                          IServerChannelSinkProvider sinkProvider)\r
69                 {\r
70                         _portName = portName;\r
71 \r
72                         if (IpcChannel.IsUnix)\r
73                                 _innerChannel = new Unix.IpcServerChannel (name, portName, sinkProvider);\r
74                         else\r
75                                 _innerChannel = new Win32.IpcServerChannel (name, portName, sinkProvider);\r
76                 }\r
77         \r
78                 public IpcServerChannel (string name, string portName)\r
79                 {\r
80                         _portName = portName;\r
81 \r
82                         if (IpcChannel.IsUnix)\r
83                                 _innerChannel = new Unix.IpcServerChannel (name, portName);\r
84                         else\r
85                                 _innerChannel = new Win32.IpcServerChannel (name, portName);\r
86                 }\r
87 \r
88                 public string ChannelName\r
89                 {\r
90                         get { return ((IChannel)_innerChannel).ChannelName; }\r
91                 }\r
92 \r
93                 public int ChannelPriority\r
94                 {\r
95                         get { return ((IChannel)_innerChannel).ChannelPriority; }\r
96                 }\r
97 \r
98                 public string Parse (string url, out string objectURI)\r
99                 {\r
100                         return ((IChannel)_innerChannel).Parse (url, out objectURI);\r
101                 }\r
102 \r
103                 public object ChannelData\r
104                 {\r
105                         get { return _innerChannel.ChannelData; }\r
106                 }\r
107 \r
108                 public virtual string[] GetUrlsForUri (string objectUri)\r
109                 {\r
110                         return _innerChannel.GetUrlsForUri (objectUri);\r
111                 }\r
112 \r
113                 public void StartListening (object data)\r
114                 {\r
115                         _innerChannel.StartListening (data);\r
116                 }\r
117 \r
118                 public void StopListening (object data)\r
119                 {\r
120                         _innerChannel.StopListening (data);\r
121                 }\r
122         \r
123                 public string GetChannelUri ()\r
124                 {\r
125                         // There is no interface for this member,\r
126                         // so we cannot delegate to the inner channel.\r
127                         return Win32.IpcChannelHelper.SchemeStart + _portName;\r
128                 }\r
129         }\r
130 }\r
131 \r
132 #endif\r