* ReturnMessage.cs: Implemented property Properties
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Messaging / RemotingSurrogateSelector.cs
1 //
2 // System.Runtime.Remoting.Messaging.RemotingSurrogateSelector.cs
3 //
4 // Author: Duncan Mak  (duncan@ximian.com)
5 //         Lluis Sanchez Gual (lluis@ideary.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
11 using System.Runtime.Serialization;
12
13 namespace System.Runtime.Remoting.Messaging {
14
15         public class RemotingSurrogateSelector : ISurrogateSelector
16         {
17                 ISurrogateSelector _next;
18                 static ObjRefSurrogate _objRefSurrogate = new ObjRefSurrogate();
19
20                 public RemotingSurrogateSelector ()
21                 {
22                 }
23                 
24                 [MonoTODO]
25                 public MessageSurrogateFilter Filter {
26                         get { throw new NotImplementedException (); }
27                         set { throw new NotImplementedException (); }
28                 }
29
30                 public virtual void ChainSelector (ISurrogateSelector selector)
31                 {
32                         if (_next != null) selector.ChainSelector (_next);
33                         _next = selector;
34                 }
35
36                 public virtual ISurrogateSelector GetNextSelector()
37                 {
38                         return _next;
39                 }
40
41                 [MonoTODO]
42                 public object GetRootObject ()
43                 {
44                         throw new NotImplementedException ();
45                 }
46
47                 public virtual ISerializationSurrogate GetSurrogate (
48                         Type type, StreamingContext context, out ISurrogateSelector ssout)
49                 {
50                         if (type.IsSubclassOf (typeof(MarshalByRefObject)))
51                         {
52                                 ssout = this;
53                                 return _objRefSurrogate;
54                         }
55                         if (_next != null) return _next.GetSurrogate (type, context, out ssout);
56
57                         ssout = null;
58                         return null;
59                 }
60
61                 [MonoTODO]
62                 public void SetRootObject (object obj)
63                 {
64                         if (obj == null)
65                                 throw new ArgumentNullException ();
66                         
67                         throw new NotImplementedException ();
68                 }
69                 
70                 [MonoTODO]
71                 public virtual void UseSoapFormat ()
72                 {
73                         throw new NotImplementedException ();
74                 }
75         }
76
77         public class ObjRefSurrogate : ISerializationSurrogate
78         {
79                 public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
80                 {
81                         RemotingServices.GetObjectData (obj, info, context);
82                         info.AddValue ("fIsMarshalled", 0);
83                 }
84
85                 public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
86                 {
87                         // ObjRef is deserialized using the IObjectReference interface
88                         throw new NotSupportedException ("Do not use RemotingSurrogateSelector when deserializating");
89                 }
90         }
91 }