2 // System.Runtime.Remoting.Messaging.RemotingSurrogateSelector.cs
4 // Author: Duncan Mak (duncan@ximian.com)
5 // Lluis Sanchez Gual (lluis@ideary.com)
7 // (C) Ximian, Inc. http://www.ximian.com
11 using System.Runtime.Serialization;
13 namespace System.Runtime.Remoting.Messaging {
15 public class RemotingSurrogateSelector : ISurrogateSelector
17 ISurrogateSelector _next;
18 static ObjRefSurrogate _objRefSurrogate = new ObjRefSurrogate();
20 public RemotingSurrogateSelector ()
25 public MessageSurrogateFilter Filter {
26 get { throw new NotImplementedException (); }
27 set { throw new NotImplementedException (); }
30 public virtual void ChainSelector (ISurrogateSelector selector)
32 if (_next != null) selector.ChainSelector (_next);
36 public virtual ISurrogateSelector GetNextSelector()
42 public object GetRootObject ()
44 throw new NotImplementedException ();
47 public virtual ISerializationSurrogate GetSurrogate (
48 Type type, StreamingContext context, out ISurrogateSelector ssout)
50 if (type.IsSubclassOf (typeof(MarshalByRefObject)))
53 return _objRefSurrogate;
55 if (_next != null) return _next.GetSurrogate (type, context, out ssout);
62 public void SetRootObject (object obj)
65 throw new ArgumentNullException ();
67 throw new NotImplementedException ();
71 public virtual void UseSoapFormat ()
73 throw new NotImplementedException ();
77 public class ObjRefSurrogate : ISerializationSurrogate
79 public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
81 RemotingServices.GetObjectData (obj, info, context);
82 info.AddValue ("fIsMarshalled", 0);
85 public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
87 // ObjRef is deserialized using the IObjectReference interface
88 throw new NotSupportedException ("Do not use RemotingSurrogateSelector when deserializating");