System.Runtime.Serialization.SurrogateSelector Class

Assembly: Mscorlib.dll
Namespace: System.Runtime.Serialization
Summary
Assists formatters in selection of the serialization surrogate to delegate the serialization or deserialization process to.
C# Syntax:
public class SurrogateSelector : ISurrogateSelector
Remarks
A serialization surrogate gives the users an object that can handle the serialization requirements of a different object and can transform the serialized data if necessary.
See also:
System.Runtime.Serialization Namespace

System.Runtime.Serialization.SurrogateSelector Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the SurrogateSelector class.
Public Methods
AddSurrogate Adds a surrogate to the list of checked surrogates.
ChainSelector Adds the specified ISurrogateSelector that can handle a particular object type to the list of surrogates.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetNextSelector Returns the next selector on the chain of selectors.
GetSurrogate Returns the surrogate for a particular type.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
RemoveSurrogate Removes the surrogate associated with a given type.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Runtime.Serialization.SurrogateSelector Member Details

ctor #1
Summary
Initializes a new instance of the SurrogateSelector class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public SurrogateSelector();

Return to top


Method: AddSurrogate(
   Type type,
   StreamingContext context,
   ISerializationSurrogate surrogate
)
Summary
Adds a surrogate to the list of checked surrogates.
C# Syntax:
public virtual void AddSurrogate(
   Type type,
   StreamingContext context,
   ISerializationSurrogate surrogate
);
Parameters:

type

The Type for which the surrogate is required

context

The context-specific data.

surrogate

The surrogate to call for this type.

Exceptions
Exception Type Condition
ArgumentNullException The type or surrogate parameter is null.
ArgumentException A surrogate already exists for this type and context.

Return to top


Method: ChainSelector(
   ISurrogateSelector selector
)
Summary
Adds the specified ISurrogateSelector that can handle a particular object type to the list of surrogates.
C# Syntax:
public virtual void ChainSelector(
   ISurrogateSelector selector
);
Parameters:

selector

The surrogate selector to add.

Exceptions
Exception Type Condition
ArgumentNullException The selector parameter is null.
SerializationException The selector is already on the list of selectors.
Implements:
ISurrogateSelector.ChainSelector
Remarks
The last selector added to the list will be the first one checked.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~SurrogateSelector();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetNextSelector()
Summary
Returns the next selector on the chain of selectors.
C# Syntax:
public virtual ISurrogateSelector GetNextSelector();
Return Value:
The next ISurrogateSelector on the chain of selectors.
Implements:
ISurrogateSelector.GetNextSelector

Return to top


Method: GetSurrogate(
   Type type,
   StreamingContext context,
   out ISurrogateSelector selector
)
Summary
Returns the surrogate for a particular type.
C# Syntax:
public virtual ISerializationSurrogate GetSurrogate(
   Type type,
   StreamingContext context,
   out ISurrogateSelector selector
);
Parameters:

type

The Type for which the surrogate is requested.

context

The streaming context.

selector

The surrogate to use.

Return Value:
The surrogate for a particular type.
Exceptions
Exception Type Condition
ArgumentNullException The type parameter is null.
Implements:
ISurrogateSelector.GetSurrogate
Remarks
If the current selector cannot provide a surrogate, it checks all its child objects before returning null.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: RemoveSurrogate(
   Type type,
   StreamingContext context
)
Summary
Removes the surrogate associated with a given type.
C# Syntax:
public virtual void RemoveSurrogate(
   Type type,
   StreamingContext context
);
Parameters:

type

The Type for which to remove the surrogate.

context

The StreamingContext for the current surrogate.

Exceptions
Exception Type Condition
ArgumentNullException The type parameter is null.
Remarks
This method does not check chained surrogates.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.