Export (0) Print
Expand All

NetDataContractSerializer.NetDataContractSerializer(StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector) Constructor

Initializes a new instance of the NetDataContractSerializer class with the supplied context data; in addition, specifies the maximum number of items in the object to be serialized, and parameters to specify whether extra data is ignored, the assembly loading method, and a surrogate selector.

Namespace: System.Runtime.Serialization
Assembly: System.Runtime.Serialization (in system.runtime.serialization.dll)

public NetDataContractSerializer (
	StreamingContext context,
	int maxItemsInObjectGraph,
	bool ignoreExtensionDataObject,
	FormatterAssemblyStyle assemblyFormat,
	ISurrogateSelector surrogateSelector
)
public NetDataContractSerializer (
	StreamingContext context, 
	int maxItemsInObjectGraph, 
	boolean ignoreExtensionDataObject, 
	FormatterAssemblyStyle assemblyFormat, 
	ISurrogateSelector surrogateSelector
)
public function NetDataContractSerializer (
	context : StreamingContext, 
	maxItemsInObjectGraph : int, 
	ignoreExtensionDataObject : boolean, 
	assemblyFormat : FormatterAssemblyStyle, 
	surrogateSelector : ISurrogateSelector
)
Not applicable.

Parameters

context

A StreamingContext that contains context data.

maxItemsInObjectGraph

The maximum number of items in the graph to serialize or deserialize.

ignoreExtensionDataObject

true to ignore the data supplied by an extension of the type; otherwise, false.

assemblyFormat

A FormatterAssemblyStyle enumeration value that specifies a method for locating and loading assemblies.

surrogateSelector

An implementation of the ISurrogateSelector.

Exception typeCondition

ArgumentNullException

maxItemsInObjectGraph value is less than 0.

The ignoreExtensionDataObject parameter is used when the IExtensibleDataObject interface is implemented in the class that that is being seriailized or deserialized.

The following example creates an instance of the NetDataContractSerializer using a StreamingContext. The code also sets the ignoreExtensionDataObject, and specifies an implementation of the ISurrogateSelector interface to handle to assist the serializer when selecting a surrogate (for deserializing legacy types).

public static void Constructor5()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);

    // Create an instance of a class that implements the 
    // ISurrogateSelector interface. The implementation code
    // is not shown here.
    MySelector mySurrogateSelector = new MySelector();

    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);

    // Other code not shown.
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft