mscorlib(4.0.0.0) API with additions
RemotingSurrogateSelector.cs
3 using System.Security;
5 
7 {
9  [SecurityCritical]
10  [ComVisible(true)]
11  [SecurityPermission(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
13  {
14  private static Type s_IMethodCallMessageType = typeof(IMethodCallMessage);
15 
16  private static Type s_IMethodReturnMessageType = typeof(IMethodReturnMessage);
17 
18  private static Type s_ObjRefType = typeof(ObjRef);
19 
20  private object _rootObj;
21 
22  private ISurrogateSelector _next;
23 
24  private RemotingSurrogate _remotingSurrogate = new RemotingSurrogate();
25 
26  private ObjRefSurrogate _objRefSurrogate = new ObjRefSurrogate();
27 
28  private ISerializationSurrogate _messageSurrogate;
29 
30  private MessageSurrogateFilter _filter;
31 
35  {
36  get
37  {
38  return _filter;
39  }
40  set
41  {
42  _filter = value;
43  }
44  }
45 
48  {
49  _messageSurrogate = new MessageSurrogate(this);
50  }
51 
55  public void SetRootObject(object obj)
56  {
57  if (obj == null)
58  {
59  throw new ArgumentNullException("obj");
60  }
61  _rootObj = obj;
62  (_messageSurrogate as SoapMessageSurrogate)?.SetRootObject(_rootObj);
63  }
64 
67  public object GetRootObject()
68  {
69  return _rootObj;
70  }
71 
74  [SecurityCritical]
75  public virtual void ChainSelector(ISurrogateSelector selector)
76  {
77  _next = selector;
78  }
79 
85  [SecurityCritical]
87  {
88  if (type == null)
89  {
90  throw new ArgumentNullException("type");
91  }
92  if (type.IsMarshalByRef)
93  {
94  ssout = this;
95  return _remotingSurrogate;
96  }
97  if (s_IMethodCallMessageType.IsAssignableFrom(type) || s_IMethodReturnMessageType.IsAssignableFrom(type))
98  {
99  ssout = this;
100  return _messageSurrogate;
101  }
102  if (s_ObjRefType.IsAssignableFrom(type))
103  {
104  ssout = this;
105  return _objRefSurrogate;
106  }
107  if (_next != null)
108  {
109  return _next.GetSurrogate(type, context, out ssout);
110  }
111  ssout = null;
112  return null;
113  }
114 
117  [SecurityCritical]
119  {
120  return _next;
121  }
122 
124  public virtual void UseSoapFormat()
125  {
126  _messageSurrogate = new SoapMessageSurrogate(this);
127  ((SoapMessageSurrogate)_messageSurrogate).SetRootObject(_rootObj);
128  }
129  }
130 }
virtual ISurrogateSelector GetNextSelector()
Returns the next T:System.Runtime.Serialization.ISurrogateSelector in the chain of surrogate selector...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
virtual void UseSoapFormat()
Sets up the current surrogate selector to use the SOAP format.
Defines the method call return message interface.
Defines the method call message interface.
virtual void ChainSelector(ISurrogateSelector selector)
Adds the specified T:System.Runtime.Serialization.ISurrogateSelector to the surrogate selector chain.
Definition: __Canon.cs:3
Stores all relevant information required to generate a proxy in order to communicate with a remote ob...
Definition: ObjRef.cs:19
ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
Finds the surrogate that represents the specified object's type, starting with the specified surrogat...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
Selects the remoting surrogate that can be used to serialize an object that derives from a T:System....
void SetRootObject(object obj)
Sets the object at the root of the object graph.
SecurityAction
Specifies the security actions that can be performed using declarative security.
object GetRootObject()
Returns the object at the root of the object graph.
RemotingSurrogateSelector()
Initializes a new instance of the T:System.Runtime.Remoting.Messaging.RemotingSurrogateSelector class...
Implements a serialization surrogate selector that allows one object to perform serialization and des...
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
virtual ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector ssout)
Returns the appropriate surrogate for the given type in the given context.
Indicates a serialization surrogate selector class.
MessageSurrogateFilter Filter
Gets or sets the T:System.Runtime.Remoting.Messaging.MessageSurrogateFilter delegate for the current ...
bool IsMarshalByRef
Gets a value indicating whether the T:System.Type is marshaled by reference.
Definition: Type.cs:728
delegate bool MessageSurrogateFilter(string key, object value)
Determines whether the T:System.Runtime.Remoting.Messaging.RemotingSurrogateSelector class should ign...
SecurityPermissionFlag
Specifies access flags for the security permission object.
virtual bool IsAssignableFrom(Type c)
Determines whether an instance of a specified type can be assigned to an instance of the current type...
Definition: Type.cs:2707