NetDataContractSerializer Construtores

Definição

Inicializa uma nova instância da classe NetDataContractSerializer.Initializes a new instance of the NetDataContractSerializer class.

Sobrecargas

NetDataContractSerializer()

Inicializa uma nova instância da classe NetDataContractSerializer.Initializes a new instance of the NetDataContractSerializer class.

NetDataContractSerializer(StreamingContext)

Inicializa uma nova instância da classe NetDataContractSerializer com os dados de contexto de fluxo fornecidos.Initializes a new instance of the NetDataContractSerializer class with the supplied streaming context data.

NetDataContractSerializer(String, String)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o elemento raiz XML fornecidos.Initializes a new instance of the NetDataContractSerializer class with the supplied XML root element and namespace.

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString)

Inicializa uma nova instância da classe NetDataContractSerializer com dois parâmetros do tipo XmlDictionaryString que contêm o elemento raiz e o namespace usado para especificar o conteúdo.Initializes a new instance of the NetDataContractSerializer class with two parameters of type XmlDictionaryString that contain the root element and namespace used to specify the content.

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

Inicializa uma nova instância da classe NetDataContractSerializer com os dados de contexto fornecidos; além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras serão ignorados, o método de carregamento do assembly e um seletor substituto.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.

NetDataContractSerializer(String, String, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o nome de raiz e dados de contexto fornecidos; além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras serão ignorados, o método de carregamento do assembly e um seletor substituto.Initializes a new instance of the NetDataContractSerializer class with the supplied context data and root name and namespace; 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.

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o nome de raiz e dados de contexto fornecidos (como parâmetros XmlDictionaryString); além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras encontrados serão ignorados, o método de carregamento de assembly e um seletor substituto.Initializes a new instance of the NetDataContractSerializer class with the supplied context data, and root name and namespace (as XmlDictionaryString parameters); in addition, specifies the maximum number of items in the object to be serialized, and parameters to specify whether extra data found is ignored, assembly loading method, and a surrogate selector.

NetDataContractSerializer()

Inicializa uma nova instância da classe NetDataContractSerializer.Initializes a new instance of the NetDataContractSerializer class.

public:
 NetDataContractSerializer();
public NetDataContractSerializer ();
Public Sub New ()

Exemplos

public static void Constructor1()
{
    // Create an instance of the NetDataContractSerializer.
    NetDataContractSerializer ser =
        new NetDataContractSerializer();
    // Other code not shown.
}
Public Shared Sub Constructor1() 
    ' Create an instance of the NetDataContractSerializer.
    Dim ser As New System.Runtime.Serialization.NetDataContractSerializer()

End Sub 

' Other code not shown.

Aplica-se a

NetDataContractSerializer(StreamingContext)

Inicializa uma nova instância da classe NetDataContractSerializer com os dados de contexto de fluxo fornecidos.Initializes a new instance of the NetDataContractSerializer class with the supplied streaming context data.

public:
 NetDataContractSerializer(System::Runtime::Serialization::StreamingContext context);
public NetDataContractSerializer (System.Runtime.Serialization.StreamingContext context);
new System.Runtime.Serialization.NetDataContractSerializer : System.Runtime.Serialization.StreamingContext -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (context As StreamingContext)

Parâmetros

context
StreamingContext

Um StreamingContext que contém dados de contexto.A StreamingContext that contains context data.

Exemplos

O exemplo a seguir cria uma instância do NetDataContractSerializer usando um StreamingContext .The following example creates an instance of the NetDataContractSerializer using a StreamingContext.

public static void Constructor2()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);
    // Create a DatatContractSerializer with the collection.
    NetDataContractSerializer ser2 = new NetDataContractSerializer(sc);

    // Other code not shown.
}
Public Shared Sub Constructor2() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    ' Create a DatatContractSerializer with the collection.
    Dim ser2 As New System.Runtime.Serialization.NetDataContractSerializer(sc)

   ' Other code not shown.
End Sub 

Comentários

A StreamingContext classe permite que você transmita dados de contexto específicos do usuário a serem usados durante a leitura e a gravação de objetos.The StreamingContext class allows you to pass in user-specific context data to use while reading and writing objects.

Aplica-se a

NetDataContractSerializer(String, String)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o elemento raiz XML fornecidos.Initializes a new instance of the NetDataContractSerializer class with the supplied XML root element and namespace.

public:
 NetDataContractSerializer(System::String ^ rootName, System::String ^ rootNamespace);
public NetDataContractSerializer (string rootName, string rootNamespace);
new System.Runtime.Serialization.NetDataContractSerializer : string * string -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As String, rootNamespace As String)

Parâmetros

rootName
String

O nome do elemento XML que inclui o conteúdo para serializar ou desserializar.The name of the XML element that encloses the content to serialize or deserialize.

rootNamespace
String

O namespace do elemento XML que inclui o conteúdo a ser serializado ou desserializado.The namespace of the XML element that encloses the content to serialize or deserialize.

Exemplos

O exemplo a seguir cria uma instância do que DataContractSerializer especifica o elemento raiz XML e o namespace que será esperado ao desserializar um objeto.The following example creates an instance of the DataContractSerializer specifying the XML root element and namespace it will expect when deserializing an object.

public static void Constructor3()
{
    // Create an instance of the NetDataContractSerializer
    // specifying the name and namespace as strings.
    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        "Customer",
        "http://www.contoso.com");
    // Other code not shown.
}
Public Shared Sub Constructor3() 
    ' Create an instance of the NetDataContractSerializer
    ' specifying the name and namespace as strings.
    Dim ser As New System.Runtime.Serialization. _
       NetDataContractSerializer("Customer", "http://www.contoso.com")

   ' Other code not shown.

End Sub 

Aplica-se a

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString)

Inicializa uma nova instância da classe NetDataContractSerializer com dois parâmetros do tipo XmlDictionaryString que contêm o elemento raiz e o namespace usado para especificar o conteúdo.Initializes a new instance of the NetDataContractSerializer class with two parameters of type XmlDictionaryString that contain the root element and namespace used to specify the content.

public:
 NetDataContractSerializer(System::Xml::XmlDictionaryString ^ rootName, System::Xml::XmlDictionaryString ^ rootNamespace);
public NetDataContractSerializer (System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace);
new System.Runtime.Serialization.NetDataContractSerializer : System.Xml.XmlDictionaryString * System.Xml.XmlDictionaryString -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As XmlDictionaryString, rootNamespace As XmlDictionaryString)

Parâmetros

rootName
XmlDictionaryString

Um XmlDictionaryString que contém o nome do elemento XML que inclui o conteúdo a serializar ou desserializar.An XmlDictionaryString that contains the name of the XML element that encloses the content to serialize or deserialize.

rootNamespace
XmlDictionaryString

Um XmlDictionaryString que contém o namespace do elemento XML que inclui o conteúdo a serializar ou desserializar.An XmlDictionaryString that contains the namespace of the XML element that encloses the content to serialize or deserialize.

Exemplos

O exemplo a seguir cria uma instância do que DataContractSerializer especifica o elemento raiz XML e o namespace (como XmlDictionaryString argumentos) que será esperado ao desserializar um objeto.The following example creates an instance of the DataContractSerializer specifying the XML root element and namespace (as XmlDictionaryString arguments) it will expect when deserializing an object.

public static void Constructor4()
{
    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    // Initialize the out variables.
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // Create the serializer.
    NetDataContractSerializer ser =
        new NetDataContractSerializer(
        name_value,
        ns_value);
    // Other code not shown.
}
 Public Shared Sub Constructor4() 
     ' Create an XmlDictionary and add values to it.
     Dim d As New XmlDictionary()
     Dim name_value As XmlDictionaryString =d.Add("Customer")
     Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
     
     ' Create the serializer.
     Dim ser As New System.Runtime.Serialization. _
        NetDataContractSerializer(name_value, ns_value)

     ' Other code not shown.
 
 End Sub 

Comentários

O XmlDictionaryString pode ser usado para otimizar o desempenho quando o mesmo conjunto de cadeias de caracteres é usado em instâncias de objetos.The XmlDictionaryString can be used to optimize performance when the same set of strings is used across object instances.

Aplica-se a

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

Inicializa uma nova instância da classe NetDataContractSerializer com os dados de contexto fornecidos; além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras serão ignorados, o método de carregamento do assembly e um seletor substituto.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.

public:
 NetDataContractSerializer(System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer (System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

Parâmetros

context
StreamingContext

Um StreamingContext que contém dados de contexto.A StreamingContext that contains context data.

maxItemsInObjectGraph
Int32

O número máximo de itens no grafo a serem serializados ou desserializados.The maximum number of items in the graph to serialize or deserialize.

ignoreExtensionDataObject
Boolean

true para ignorar os dados fornecidos por uma extensão do tipo; caso contrário, false.true to ignore the data supplied by an extension of the type; otherwise, false.

assemblyFormat
FormatterAssemblyStyle

Um valor de enumeração FormatterAssemblyStyle que especifica um método para localizar e carregar assemblies.A FormatterAssemblyStyle enumeration value that specifies a method for locating and loading assemblies.

surrogateSelector
ISurrogateSelector

Uma implementação de ISurrogateSelector.An implementation of the ISurrogateSelector.

Exceções

O valor maxItemsInObjectGraph é menor que 0.maxItemsInObjectGraph value is less than 0.

Exemplos

O exemplo a seguir cria uma instância do NetDataContractSerializer usando um StreamingContext .The following example creates an instance of the NetDataContractSerializer using a StreamingContext. O código também define o ignoreExtensionDataObject e especifica uma implementação da ISurrogateSelector interface a ser manipulada para auxiliar o serializador ao selecionar um substituto (para desserialização de tipos herdados).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.
}
Public Shared Sub Constructor5() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
    NetDataContractSerializer _
    (sc, _
     65536, _
     True, _
     FormatterAssemblyStyle.Simple, _
     mySurrogateSelector)

    ' Other code not shown.
End Sub 

Comentários

O ignoreExtensionDataObject parâmetro é usado quando a IExtensibleDataObject interface é implementada na classe que está sendo serializada ou desserializada.The ignoreExtensionDataObject parameter is used when the IExtensibleDataObject interface is implemented in the class that is being serialized or deserialized.

Aplica-se a

NetDataContractSerializer(String, String, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o nome de raiz e dados de contexto fornecidos; além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras serão ignorados, o método de carregamento do assembly e um seletor substituto.Initializes a new instance of the NetDataContractSerializer class with the supplied context data and root name and namespace; 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.

public:
 NetDataContractSerializer(System::String ^ rootName, System::String ^ rootNamespace, System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer (string rootName, string rootNamespace, System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : string * string * System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As String, rootNamespace As String, context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

Parâmetros

rootName
String

O nome do elemento XML que inclui o conteúdo para serializar ou desserializar.The name of the XML element that encloses the content to serialize or deserialize.

rootNamespace
String

O namespace do elemento XML que inclui o conteúdo a ser serializado ou desserializado.The namespace of the XML element that encloses the content to serialize or deserialize.

context
StreamingContext

Um StreamingContext que contém dados de contexto.A StreamingContext that contains context data.

maxItemsInObjectGraph
Int32

O número máximo de itens no grafo a serem serializados ou desserializados.The maximum number of items in the graph to serialize or deserialize.

ignoreExtensionDataObject
Boolean

true para ignorar os dados fornecidos por uma extensão do tipo; caso contrário, false.true to ignore the data supplied by an extension of the type; otherwise, false.

assemblyFormat
FormatterAssemblyStyle

Um valor de enumeração FormatterAssemblyStyle que especifica um método para localizar e carregar assemblies.A FormatterAssemblyStyle enumeration value that specifies a method for locating and loading assemblies.

surrogateSelector
ISurrogateSelector

Uma implementação de IDataContractSurrogate para lidar com o tipo herdado.An implementation of the IDataContractSurrogate to handle the legacy type.

Exceções

O valor maxItemsInObjectGraph é menor que 0.maxItemsInObjectGraph value is less than 0.

Exemplos

O exemplo a seguir cria uma instância do que NetDataContractSerializer especifica o nome do elemento XML e o namespace a ser esperado ao desserializar.The following example creates an instance of the NetDataContractSerializer specifying the XML element name and namespace to expect when deserializing. O código também define o ignoreExtensionDataObject e especifica uma implementação da ISurrogateSelector interface a ser manipulada para auxiliar o serializador ao selecionar um substituto (para desserialização de tipos herdados).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 Constructor6()
{
    // 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(
        "Customer",
        "http://www.contoso.com",
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);
    // Other code not shown.
}
Public Shared Sub Constructor6() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
      NetDataContractSerializer( _
      "Customer", _
      "http://www.contoso.com", _
      sc, _
      65536, _
      True, _
      FormatterAssemblyStyle.Simple, _
      mySurrogateSelector)

    ' Other code not shown.            

End Sub 

Comentários

O ignoreExtensionDataObject parâmetro é usado quando a IExtensibleDataObject interface é implementada na classe que está sendo serializada ou desserializada.The ignoreExtensionDataObject parameter is used when the IExtensibleDataObject interface is implemented in the class that is being serialized or deserialized.

Aplica-se a

NetDataContractSerializer(XmlDictionaryString, XmlDictionaryString, StreamingContext, Int32, Boolean, FormatterAssemblyStyle, ISurrogateSelector)

Inicializa uma nova instância da classe NetDataContractSerializer com o namespace e o nome de raiz e dados de contexto fornecidos (como parâmetros XmlDictionaryString); além disso, especifica o número máximo de itens no objeto a serem serializados e os parâmetros para especificar se os dados extras encontrados serão ignorados, o método de carregamento de assembly e um seletor substituto.Initializes a new instance of the NetDataContractSerializer class with the supplied context data, and root name and namespace (as XmlDictionaryString parameters); in addition, specifies the maximum number of items in the object to be serialized, and parameters to specify whether extra data found is ignored, assembly loading method, and a surrogate selector.

public:
 NetDataContractSerializer(System::Xml::XmlDictionaryString ^ rootName, System::Xml::XmlDictionaryString ^ rootNamespace, System::Runtime::Serialization::StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System::Runtime::Serialization::Formatters::FormatterAssemblyStyle assemblyFormat, System::Runtime::Serialization::ISurrogateSelector ^ surrogateSelector);
public NetDataContractSerializer (System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, System.Runtime.Serialization.StreamingContext context, int maxItemsInObjectGraph, bool ignoreExtensionDataObject, System.Runtime.Serialization.Formatters.FormatterAssemblyStyle assemblyFormat, System.Runtime.Serialization.ISurrogateSelector surrogateSelector);
new System.Runtime.Serialization.NetDataContractSerializer : System.Xml.XmlDictionaryString * System.Xml.XmlDictionaryString * System.Runtime.Serialization.StreamingContext * int * bool * System.Runtime.Serialization.Formatters.FormatterAssemblyStyle * System.Runtime.Serialization.ISurrogateSelector -> System.Runtime.Serialization.NetDataContractSerializer
Public Sub New (rootName As XmlDictionaryString, rootNamespace As XmlDictionaryString, context As StreamingContext, maxItemsInObjectGraph As Integer, ignoreExtensionDataObject As Boolean, assemblyFormat As FormatterAssemblyStyle, surrogateSelector As ISurrogateSelector)

Parâmetros

rootName
XmlDictionaryString

Um XmlDictionaryString que contém o elemento raiz do conteúdo.An XmlDictionaryString that contains the root element of the content.

rootNamespace
XmlDictionaryString

Um XmlDictionaryString que contém o namespace do elemento raiz.An XmlDictionaryString that contains the namespace of the root element.

context
StreamingContext

Um StreamingContext que contém dados de contexto.A StreamingContext that contains context data.

maxItemsInObjectGraph
Int32

O número máximo de itens no grafo a serem serializados ou desserializados.The maximum number of items in the graph to serialize or deserialize.

ignoreExtensionDataObject
Boolean

true para ignorar os dados fornecidos por uma extensão do tipo; caso contrário, false.true to ignore the data supplied by an extension of the type; otherwise, false.

assemblyFormat
FormatterAssemblyStyle

Um valor de enumeração FormatterAssemblyStyle que especifica um método para localizar e carregar assemblies.A FormatterAssemblyStyle enumeration value that specifies a method for locating and loading assemblies.

surrogateSelector
ISurrogateSelector

Uma implementação de IDataContractSurrogate para lidar com o tipo herdado.An implementation of the IDataContractSurrogate to handle the legacy type.

Exceções

O valor maxItemsInObjectGraph é menor que 0.maxItemsInObjectGraph value is less than 0.

Exemplos

O exemplo a seguir cria uma instância do NetDataContractSerializer especificando o nome do elemento XML e o namespace (como XmlDictionaryString argumentos) para esperar ao desserializar.The following example creates an instance of the NetDataContractSerializer specifying the XML element name and namespace (as XmlDictionaryString arguments) to expect when deserializing. O código também define o ignoreExtensionDataObject e especifica uma implementação da ISurrogateSelector interface a ser manipulada para auxiliar o serializador ao selecionar um substituto (para desserialização de tipos herdados).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 Constructor7()
{
    // Create an instance of the StreamingContext to hold
    // context data.
    StreamingContext sc = new StreamingContext
        (StreamingContextStates.CrossAppDomain);

    // Create an XmlDictionary and add values to it.
    XmlDictionary d = new XmlDictionary();
    XmlDictionaryString name_value = d.Add("Customer");
    XmlDictionaryString ns_value = d.Add("http://www.contoso.com");

    // 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(
        name_value,
        ns_value,
        sc,
        int.MaxValue,
        true,
        FormatterAssemblyStyle.Simple,
        mySurrogateSelector);

    // Other code not shown.
}
Public Shared Sub Constructor7() 
    ' Create an instance of the StreamingContext to hold
    ' context data.
    Dim sc As New StreamingContext()
    
    ' Create an XmlDictionary and add values to it.
    Dim d As New XmlDictionary()
    Dim name_value As XmlDictionaryString =d.Add("Customer")
    Dim ns_value As XmlDictionaryString = d.Add("http://www.contoso.com")
    
    ' Create an instance of a class that implements the 
    ' ISurrogateSelector interface. The implementation code
    ' is not shown here.
    Dim mySurrogateSelector As New MySelector()
    
    Dim ser As New System.Runtime.Serialization. _
      NetDataContractSerializer( _
      name_value, _
      ns_value, _
      sc, _
      65536, _
      True, _
      FormatterAssemblyStyle.Simple, _
      mySurrogateSelector)

    ' Other code not shown.    

End Sub 

Comentários

O XmlDictionaryString pode ser usado para otimizar o desempenho quando o mesmo conjunto de cadeias de caracteres é usado em instâncias de objetos.The XmlDictionaryString can be used to optimize performance when the same set of strings is used across object instances.

O ignoreExtensionDataObject parâmetro é usado quando a IExtensibleDataObject interface é implementada na classe que está sendo serializada ou desserializada.The ignoreExtensionDataObject parameter is used when the IExtensibleDataObject interface is implemented in the class that is being serialized or deserialized.

Aplica-se a