DataContractSerializer Třída
Definice
Serializace a deserializace instance typu do datového proudu XML nebo dokumentu pomocí poskytnutého kontraktu dat.Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract. Tuto třídu nelze zdědit.This class cannot be inherited.
public ref class DataContractSerializer sealed : System::Runtime::Serialization::XmlObjectSerializer
public sealed class DataContractSerializer : System.Runtime.Serialization.XmlObjectSerializer
type DataContractSerializer = class
inherit XmlObjectSerializer
Public NotInheritable Class DataContractSerializer
Inherits XmlObjectSerializer
- Dědičnost
Příklady
Následující příklad kódu ukazuje typ pojmenovaný Person , který je serializován pomocí DataContractSerializer .The following example code shows a type named Person that is serialized by the DataContractSerializer. DataContractAttributeAtribut je použit pro třídu a DataMemberAttribute je použit pro členy k DataContractSerializer určení toho, co se má serializovat.The DataContractAttribute attribute is applied to the class, and the DataMemberAttribute is applied to members to instruct the DataContractSerializer what to serialize.
namespace DataContractSerializerExample
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
// You must apply a DataContractAttribute or SerializableAttribute
// to a class to have it serialized by the DataContractSerializer.
[DataContract(Name = "Customer", Namespace = "http://www.contoso.com")]
class Person : IExtensibleDataObject
{
[DataMember()]
public string FirstName;
[DataMember]
public string LastName;
[DataMember()]
public int ID;
public Person(string newfName, string newLName, int newID)
{
FirstName = newfName;
LastName = newLName;
ID = newID;
}
private ExtensionDataObject extensionData_Value;
public ExtensionDataObject ExtensionData
{
get
{
return extensionData_Value;
}
set
{
extensionData_Value = value;
}
}
}
public sealed class Test
{
private Test() { }
public static void Main()
{
try
{
WriteObject("DataContractSerializerExample.xml");
ReadObject("DataContractSerializerExample.xml");
}
catch (SerializationException serExc)
{
Console.WriteLine("Serialization Failed");
Console.WriteLine(serExc.Message);
}
catch (Exception exc)
{
Console.WriteLine(
"The serialization operation failed: {0} StackTrace: {1}",
exc.Message, exc.StackTrace);
}
finally
{
Console.WriteLine("Press <Enter> to exit....");
Console.ReadLine();
}
}
public static void WriteObject(string fileName)
{
Console.WriteLine(
"Creating a Person object and serializing it.");
Person p1 = new Person("Zighetti", "Barbara", 101);
FileStream writer = new FileStream(fileName, FileMode.Create);
DataContractSerializer ser =
new DataContractSerializer(typeof(Person));
ser.WriteObject(writer, p1);
writer.Close();
}
public static void ReadObject(string fileName)
{
Console.WriteLine("Deserializing an instance of the object.");
FileStream fs = new FileStream(fileName,
FileMode.Open);
XmlDictionaryReader reader =
XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
DataContractSerializer ser = new DataContractSerializer(typeof(Person));
// Deserialize the data and read it from the instance.
Person deserializedPerson =
(Person)ser.ReadObject(reader, true);
reader.Close();
fs.Close();
Console.WriteLine(String.Format("{0} {1}, ID: {2}",
deserializedPerson.FirstName, deserializedPerson.LastName,
deserializedPerson.ID));
}
}
' You must apply a DataContractAttribute or SerializableAttribute
' to a class to have it serialized by the DataContractSerializer.
<DataContract(Name := "Customer", [Namespace] := "http://www.contoso.com")> _
Class Person
Implements IExtensibleDataObject
<DataMember()> _
Public FirstName As String
<DataMember()> _
Public LastName As String
<DataMember()> _
Public ID As Integer
Public Sub New(ByVal newfName As String, ByVal newLName As String, ByVal newID As Integer)
FirstName = newfName
LastName = newLName
ID = newID
End Sub
Private extensionData_Value As ExtensionDataObject
Public Property ExtensionData() As ExtensionDataObject Implements _
IExtensibleDataObject.ExtensionData
Get
Return extensionData_Value
End Get
Set
extensionData_Value = value
End Set
End Property
End Class
NotInheritable Public Class Test
Private Sub New()
End Sub
Public Shared Sub Main()
Try
WriteObject("DataContractSerializerExample.xml")
ReadObject("DataContractSerializerExample.xml")
Catch serExc As SerializationException
Console.WriteLine("Serialization Failed")
Console.WriteLine(serExc.Message)
Catch exc As Exception
Console.WriteLine("The serialization operation failed: {0} StackTrace: {1}", exc.Message, exc.StackTrace)
Finally
Console.WriteLine("Press <Enter> to exit....")
Console.ReadLine()
End Try
End Sub
Public Shared Sub WriteObject(ByVal fileName As String)
Console.WriteLine("Creating a Person object and serializing it.")
Dim p1 As New Person("Zighetti", "Barbara", 101)
Dim writer As New FileStream(fileName, FileMode.Create)
Dim ser As New DataContractSerializer(GetType(Person))
ser.WriteObject(writer, p1)
writer.Close()
End Sub
Public Shared Sub ReadObject(ByVal fileName As String)
Console.WriteLine("Deserializing an instance of the object.")
Dim fs As New FileStream(fileName, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
Dim ser As New DataContractSerializer(GetType(Person))
' Deserialize the data and read it from the instance.
Dim deserializedPerson As Person = CType(ser.ReadObject(reader, True), Person)
reader.Close()
fs.Close()
Console.WriteLine(String.Format("{0} {1}, ID: {2}", deserializedPerson.FirstName, deserializedPerson.LastName, deserializedPerson.ID))
End Sub
End Class
Poznámky
Použijte DataContractSerializer třídu k serializaci a deserializaci instancí typu do datového proudu XML nebo dokumentu.Use the DataContractSerializer class to serialize and deserialize instances of a type into an XML stream or document. Můžete například vytvořit typ s názvem Person s vlastnostmi, které obsahují důležitá data, jako je například název a adresa.For example, you can create a type named Person with properties that contain essential data, such as a name and address. Pak můžete vytvořit a manipulovat s instancí Person třídy a zapsat všechny její hodnoty vlastností v dokumentu XML pro pozdější načtení nebo v datovém proudu XML pro okamžitou přepravu.You can then create and manipulate an instance of the Person class and write all of its property values in an XML document for later retrieval, or in an XML stream for immediate transport. Nejdůležitější, používá se DataContractSerializer k serializaci a deserializaci dat odesílaných ve zprávách Windows Communication Foundation (WCF).Most important, the DataContractSerializer is used to serialize and deserialize data sent in Windows Communication Foundation (WCF) messages. Použijte DataContractAttribute atribut na třídy a DataMemberAttribute atribut na členy třídy, chcete-li určit vlastnosti a pole, které jsou serializovány.Apply the DataContractAttribute attribute to classes, and the DataMemberAttribute attribute to class members to specify properties and fields that are serialized.
Seznam typů, které mohou být serializovány, naleznete v části typy podporované serializátorem kontraktu dat.For a list of types that can be serialized, see Types Supported by the Data Contract Serializer.
Chcete-li použít DataContractSerializer , nejprve vytvořte instanci třídy a objekt vhodný pro zápis nebo čtení formátu; například instance XmlDictionaryWriter .To use the DataContractSerializer, first create an instance of a class and an object appropriate to writing or reading the format; for example, an instance of the XmlDictionaryWriter. Pak zavolejte WriteObject metodu pro zachování dat.Then call the WriteObject method to persist the data. Chcete-li načíst data, vytvořte objekt vhodný pro čtení datového formátu (například XmlDictionaryReader pro dokument XML) a zavolejte ReadObject metodu.To retrieve data, create an object appropriate to reading the data format (such as an XmlDictionaryReader for an XML document) and call the ReadObject method.
Další informace o použití naleznete v DataContractSerializer tématu serializace a deserializace.For more information about using the DataContractSerializer, see Serialization and Deserialization.
Typ serializátoru kontraktu dat můžete nastavit pomocí elementu < DataContractSerializer > v konfiguračním souboru klientské aplikace.You can set the type of a data contract serializer using the <dataContractSerializer> element in a client application configuration file.
Příprava tříd pro serializaci nebo deserializaciPreparing Classes for Serialization or Deserialization
DataContractSerializerJe používán v kombinaci s DataContractAttribute DataMemberAttribute třídami a.The DataContractSerializer is used in combination with the DataContractAttribute and DataMemberAttribute classes. Pro přípravu třídy pro serializaci použijte DataContractAttribute pro třídu.To prepare a class for serialization, apply the DataContractAttribute to the class. Pro každého člena třídy, která vrací data, která chcete serializovat, použijte DataMemberAttribute .For each member of the class that returns data that you want to serialize, apply the DataMemberAttribute. Můžete serializovat pole a vlastnosti bez ohledu na přístupnost: privátní, chráněná, interní, chráněná interní nebo veřejná.You can serialize fields and properties, regardless of accessibility: private, protected, internal, protected internal, or public.
Například vaše schéma určuje Customer ID vlastnost s vlastností, ale již máte existující aplikaci, která používá typ Person s Name vlastností.For example, your schema specifies a Customer with an ID property, but you already have an existing application that uses a type named Person with a Name property. Chcete-li vytvořit typ, který odpovídá kontraktu, nejprve použijte DataContractAttribute pro třídu.To create a type that conforms to the contract, first apply the DataContractAttribute to the class. Pak použijte DataMemberAttribute pro každé pole nebo vlastnost, které chcete serializovat.Then apply the DataMemberAttribute to every field or property that you want to serialize.
Poznámka
Můžete použít DataMemberAttribute pro soukromé i veřejné členy.You can apply the DataMemberAttribute to both private and public members.
Konečný formát XML nemusí být text.The final format of the XML need not be text. Místo toho DataContractSerializer zapisuje data jako XML XML, což umožňuje zapisovat data do libovolného formátu rozpoznávaného XmlReader a XmlWriter .Instead, the DataContractSerializer writes the data as an XML infoset, which allows you to write the data to any format recognized by the XmlReader and XmlWriter. Doporučuje se použít XmlDictionaryReader XmlDictionaryWriter třídy a ke čtení a zápisu, protože obě jsou optimalizované pro práci s DataContractSerializer .It is recommended that you use the XmlDictionaryReader and XmlDictionaryWriter classes to read and write, because both are optimized to work with the DataContractSerializer.
Pokud vytváříte třídu, která má pole nebo vlastnosti, které musí být vyplněny před serializací nebo deserializací, použijte atributy zpětného volání, jak je popsáno v části zpětné volání serializace odolné vůči verzi.If you are creating a class that has fields or properties that must be populated before the serialization or deserialization occurs, use callback attributes, as described in Version-Tolerant Serialization Callbacks.
Přidání do kolekce známých typůAdding to the Collection of Known Types
Při serializaci nebo deserializaci objektu je vyžadován typ "známo" na DataContractSerializer .When serializing or deserializing an object, it is required that the type is "known" to the DataContractSerializer. Začněte vytvořením instance třídy, která implementuje IEnumerable<T> (například List<T> ) a přidáním známých typů do kolekce.Begin by creating an instance of a class that implements IEnumerable<T> (such as List<T>) and adding the known types to the collection. Pak vytvořte instanci s DataContractSerializer jedním z přetížení, která přebírají IEnumerable<T> (například DataContractSerializer(Type, IEnumerable<Type>) .Then create an instance of the DataContractSerializer using one of the overloads that takes the IEnumerable<T> (for example, DataContractSerializer(Type, IEnumerable<Type>).
Poznámka
Na rozdíl od jiných primitivních typů DateTimeOffset Struktura není ve výchozím nastavení známým typem, proto musí být ručně přidána do seznamu známých typů (viz známé typy kontraktu dat).Unlike other primitive types, the DateTimeOffset structure is not a known type by default, so it must be manually added to the list of known types (see Data Contract Known Types).
Dopředná kompatibilitaForward Compatibility
DataContractSerializerPochopení kontraktů dat, které byly navrženy tak, aby byly kompatibilní s budoucími verzemi smlouvy.The DataContractSerializer understands data contracts that have been designed to be compatible with future versions of the contract. Tyto typy implementují IExtensibleDataObject rozhraní.Such types implement the IExtensibleDataObject interface. Rozhraní obsahuje ExtensionData vlastnost, která vrací ExtensionDataObject objekt.The interface features the ExtensionData property that returns an ExtensionDataObject object. Další informace najdete v tématu kontrakty dat kompatibilní s dopředné.For more information, see Forward-Compatible Data Contracts.
Spouštění v částečném vztahu důvěryhodnostiRunning under Partial Trust
Při vytváření instance cílového objektu během deserializace DataContractSerializer nevolá konstruktor cílového objektu.When instantiating the target object during deserialization, the DataContractSerializer does not call the constructor of the target object. Pokud vytvoříte typ [DataContract] , který je přístupný z částečné důvěryhodnosti (to znamená, že je veřejný a v sestavení s AllowPartiallyTrustedCallers použitým atributem) a že provádí některé akce související se zabezpečením, je nutné si uvědomit, že konstruktor není volán.If you author a [DataContract] type that is accessible from partial trust (that is, it is public and in an assembly that has the AllowPartiallyTrustedCallers attribute applied) and that performs some security-related actions, you must be aware that the constructor is not called. Konkrétně následující techniky nefungují:In particular, the following techniques do not work:
Pokud se pokusíte omezit přístup s částečným vztahem důvěryhodnosti vytvořením interního nebo privátního konstruktoru nebo přidáním
LinkDemanddo konstruktoru – žádná z těchto možností nemá žádný účinek během deserializace v rámci částečného vztahu důvěryhodnosti.If you try to restrict partial trust access by making the constructor internal or private, or by adding aLinkDemandto the constructor -- neither of these have any effect during deserialization under partial trust.Pokud kódujete třídu, která předpokládá, že konstruktor je spuštěn, třída se může dostat do neplatného vnitřního stavu, který lze zneužít.If you code the class that assumes the constructor has run, the class may get into an invalid internal state that is exploitable.
Konstruktory
| DataContractSerializer(Type) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. |
| DataContractSerializer(Type, DataContractSerializerSettings) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu a nastavení.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type and settings. |
| DataContractSerializer(Type, IEnumerable<Type>) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu a kolekci známých typů, které mohou být přítomny v grafu objektů.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type, and a collection of known types that may be present in the object graph. |
| DataContractSerializer(Type, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být přítomny v grafu objektů, maximální počet položek grafu k serializaci, parametry pro ignorování neočekávaných dat, zda použít nestandardní konstruktory XML k uchování dat odkazů na objekty v grafu a náhradní pro vlastní serializaci.This method also specifies a list of known types that may be present in the object graph, the maximum number of graph items to serialize, parameters to ignore unexpected data, whether to use non-standard XML constructs to preserve object reference data in the graph, and a surrogate for custom serialization. |
| DataContractSerializer(Type, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate, DataContractResolver) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být přítomny v grafu objektů, maximální počet položek grafu k serializaci, parametry pro ignorování neočekávaných dat, zda použít nestandardní konstrukce XML k uchování dat odkazů na objekty v grafu, náhradní pro vlastní serializaci a alternativu pro |
| DataContractSerializer(Type, String, String) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu pomocí zadaného kořenového elementu XML a oboru názvů.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type using the supplied XML root element and namespace. |
| DataContractSerializer(Type, String, String, IEnumerable<Type>) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje kořenový element XML a obor názvů ve dvou parametrech řetězce a seznam známých typů, které mohou být přítomny v grafu objektů.This method also specifies the root XML element and namespace in two string parameters as well as a list of known types that may be present in the object graph. |
| DataContractSerializer(Type, String, String, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být přítomny v grafu objektů, maximální počet položek grafu k serializaci, parametry pro ignorování neočekávaných dat, zda použít nestandardní konstruktory XML k uchování dat odkazů na objekty v grafu, náhradní pro vlastní serializaci a elementu XML a oboru názvů, který obsahuje obsah.This method also specifies a list of known types that may be present in the object graph, the maximum number of graph items to serialize, parameters to ignore unexpected data, whether to use non-standard XML constructs to preserve object reference data in the graph, a surrogate for custom serialization, and the XML element and namespace that contain the content. |
| DataContractSerializer(Type, String, String, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate, DataContractResolver) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být přítomny v grafu objektů, maximální počet položek grafu k serializaci, parametry pro ignorování neočekávaných dat, zda použít nestandardní konstruktory XML k uchování dat odkazů na objekty v grafu, náhradu za vlastní serializaci, element XML a obor názvů, který obsahuje obsah, a alternativu pro mapování |
| DataContractSerializer(Type, XmlDictionaryString, XmlDictionaryString) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu pomocí kořenového elementu XML a oboru názvů zadaného prostřednictvím parametrů typu XmlDictionaryString .Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type using the XML root element and namespace specified through the parameters of type XmlDictionaryString. |
| DataContractSerializer(Type, XmlDictionaryString, XmlDictionaryString, IEnumerable<Type>) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje kořenový element XML a obor názvů ve dvou XmlDictionaryString parametrech a seznam známých typů, které mohou být přítomny v grafu objektů.This method also specifies the root XML element and namespace in two XmlDictionaryString parameters as well as a list of known types that may be present in the object graph. |
| DataContractSerializer(Type, XmlDictionaryString, XmlDictionaryString, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být přítomny v grafu objektů, maximální počet položek grafu k serializaci, parametry pro ignorování neočekávaných dat, zda použít nestandardní konstruktory XML k uchování dat odkazů na objekty v grafu, náhradu za vlastní serializaci a parametry XmlDictionaryString , které určují element XML a obor názvů obsahující obsah.This method also specifies a list of known types that may be present in the object graph, the maximum number of graph items to serialize, parameters to ignore unexpected data, whether to use non-standard XML constructs to preserve object reference data in the graph, a surrogate for custom serialization, and parameters of XmlDictionaryString that specify the XML element and namespace that contain the content. |
| DataContractSerializer(Type, XmlDictionaryString, XmlDictionaryString, IEnumerable<Type>, Int32, Boolean, Boolean, IDataContractSurrogate, DataContractResolver) |
Inicializuje novou instanci DataContractSerializer třídy pro serializaci nebo deserializaci objektu zadaného typu.Initializes a new instance of the DataContractSerializer class to serialize or deserialize an object of the specified type. Tato metoda také určuje seznam známých typů, které mohou být k dispozici v grafu objektů. maximální počet položek grafu, které mají být serializovány, parametry pro ignorování neočekávaných dat, bez ohledu na to, zda použít nestandardní konstrukce XML k uchování dat odkazů na objekty v grafu, náhrady pro vlastní serializaci, parametry XmlDictionaryString , které URČUJÍ XML element a obor názvů, který obsahuje obsah, a alternativu pro mapování |
Vlastnosti
| DataContractResolver |
Získá komponentu použitou k dynamické mapě |
| DataContractSurrogate |
Získá typ náhrady, který může roztáhnout proces serializace nebo deserializace.Gets a surrogate type that can extend the serialization or deserialization process. |
| IgnoreExtensionDataObject |
Získá hodnotu, která určuje, zda se mají ignorovat data poskytnutá rozšířením třídy při serializaci nebo deserializaci třídy.Gets a value that specifies whether to ignore data supplied by an extension of the class when the class is being serialized or deserialized. |
| KnownTypes |
Získá kolekci typů, které mohou být k dispozici v grafu objektů serializovaných pomocí této instance DataContractSerializer .Gets a collection of types that may be present in the object graph serialized using this instance of the DataContractSerializer. |
| MaxItemsInObjectGraph |
Získá maximální počet položek v grafu objektů k serializaci nebo deserializaci.Gets the maximum number of items in an object graph to serialize or deserialize. |
| PreserveObjectReferences |
Získá hodnotu, která určuje, zda se mají použít nestandardní konstrukce XML pro zachování dat odkazů na objekty.Gets a value that specifies whether to use non-standard XML constructs to preserve object reference data. |
| SerializeReadOnlyTypes |
Načte hodnotu, která určuje, zda jsou typy pouze pro čtení serializovány.Gets a value that specifies whether read-only types are serialized. |
Metody
| Equals(Object) |
Určí, zda se zadaný objekt rovná aktuálnímu objektu.Determines whether the specified object is equal to the current object. (Zděděno od Object) |
| GetHashCode() |
Slouží jako výchozí funkce hash.Serves as the default hash function. (Zděděno od Object) |
| GetType() |
Získá Type aktuální instanci.Gets the Type of the current instance. (Zděděno od Object) |
| IsStartObject(XmlDictionaryReader) |
Určuje, zda XmlDictionaryReader je umístěn na objektu, který lze deserializovat.Determines whether the XmlDictionaryReader is positioned on an object that can be deserialized. |
| IsStartObject(XmlReader) |
Určuje, zda XmlReader je umístěn na objektu, který lze deserializovat.Determines whether the XmlReader is positioned on an object that can be deserialized. |
| MemberwiseClone() |
Vytvoří kopii aktuálního seznamu Object .Creates a shallow copy of the current Object. (Zděděno od Object) |
| ReadObject(Stream) |
Přečte datový proud XML nebo dokument pomocí Stream a a vrátí deserializovaný objekt.Reads the XML stream or document with a Stream and returns the deserialized object. (Zděděno od XmlObjectSerializer) |
| ReadObject(XmlDictionaryReader) |
Přečte dokument XML nebo Stream pomocí XmlDictionaryReader a a vrátí deserializovaný objekt.Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object. (Zděděno od XmlObjectSerializer) |
| ReadObject(XmlDictionaryReader, Boolean) |
Přečte datový proud XML pomocí XmlDictionaryReader a a vrátí deserializovaný objekt a také určuje, zda je před čtením jeho hodnoty provedena kontrola pro ověření názvu objektu.Reads the XML stream with an XmlDictionaryReader and returns the deserialized object, and also specifies whether a check is made to verify the object name before reading its value. |
| ReadObject(XmlDictionaryReader, Boolean, DataContractResolver) |
Přečte dokument XML nebo datový proud dokumentu a vrátí deserializovaný objekt.Reads an XML document or document stream and returns the deserialized object. Metoda obsahuje parametr pro určení, zda je ověřen název objektu, a překladač pro mapování |
| ReadObject(XmlReader) |
Přečte datový proud XML pomocí XmlReader a a vrátí deserializovaný objekt.Reads the XML stream with an XmlReader and returns the deserialized object. |
| ReadObject(XmlReader, Boolean) |
Přečte datový proud XML pomocí XmlReader a a vrátí deserializovaný objekt a také určuje, zda je před čtením jeho hodnoty provedena kontrola pro ověření názvu objektu.Reads the XML stream with an XmlReader and returns the deserialized object, and also specifies whether a check is made to verify the object name before reading its value. |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt.Returns a string that represents the current object. (Zděděno od Object) |
| WriteEndObject(XmlDictionaryWriter) |
Zapíše uzavírací element XML pomocí XmlDictionaryWriter .Writes the closing XML element using an XmlDictionaryWriter. |
| WriteEndObject(XmlWriter) |
Zapíše uzavírací element XML pomocí XmlWriter .Writes the closing XML element using an XmlWriter. |
| WriteObject(Stream, Object) |
Zapíše úplný obsah objektu (začátek, obsah a konec) objektu do dokumentu XML nebo datového proudu se zadaným parametrem Stream .Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified Stream. (Zděděno od XmlObjectSerializer) |
| WriteObject(XmlDictionaryWriter, Object) |
Zapíše úplný obsah objektu (začátek, obsah a konec) objektu do dokumentu XML nebo datového proudu se zadaným parametrem XmlDictionaryWriter .Writes the complete content (start, content, and end) of the object to the XML document or stream with the specified XmlDictionaryWriter. (Zděděno od XmlObjectSerializer) |
| WriteObject(XmlDictionaryWriter, Object, DataContractResolver) |
Zapisuje všechna data objektů (spouští XML element, Content a ohraničující element) do dokumentu XML nebo datového proudu pomocí zadaného implementace XmlDictionaryWriter.Writes all the object data (starting XML element, content, and enclosing element) to an XML document or stream using the specified XmlDictionaryWriter. Metoda zahrnuje překladač pro |
| WriteObject(XmlWriter, Object) |
Zapisuje všechna data objektů (spouští XML element, Content a uzavírací element) do dokumentu XML nebo datového proudu pomocí XmlWriter .Writes all the object data (starting XML element, content, and closing element) to an XML document or stream with an XmlWriter. |
| WriteObjectContent(XmlDictionaryWriter, Object) |
Zapíše obsah XML pomocí XmlDictionaryWriter .Writes the XML content using an XmlDictionaryWriter. |
| WriteObjectContent(XmlWriter, Object) |
Zapíše obsah XML pomocí XmlWriter .Writes the XML content using an XmlWriter. |
| WriteStartObject(XmlDictionaryWriter, Object) |
Zapíše otevírání XML elementu pomocí XmlDictionaryWriter .Writes the opening XML element using an XmlDictionaryWriter. |
| WriteStartObject(XmlWriter, Object) |
Zapíše otevírání XML elementu pomocí XmlWriter .Writes the opening XML element using an XmlWriter. |
Metody rozšíření
| GetSerializationSurrogateProvider(DataContractSerializer) |
Vrátí zprostředkovatele náhradní serializace pro tento serializátor.Returns the surrogate serialization provider for this serializer. |
| SetSerializationSurrogateProvider(DataContractSerializer, ISerializationSurrogateProvider) |
Určuje poskytovatele náhradní serializace DataContractSerializer .Specifies a surrogate serialization provider for this DataContractSerializer. |
Platí pro
Bezpečný přístup z více vláken
Instance této třídy jsou vláknově bezpečné, s výjimkou případů, kdy je instance použita s implementací IDataContractSurrogate nebo DataContractResolver .Instances of this class are thread safe except when the instance is used with an implementation of the IDataContractSurrogate or DataContractResolver.