Talking about the sequence of objects (Serialize)

xiaoxiao2021-03-06  52

Squiring from the 9CBS Forum

Serialization is a process of converting the object state to a fully or transmitted format. The relative sequence is reverse selecente, and it converts the stream to an object. These two processes are combined to make data easily store and transmit.

.NET Framework provides two serialization techniques:

Binary serialization keep the type of assault, which is useful for retention objects between applications. For example, by sequentially serializing the object to the clipboard, the object can be shared between different applications. You can serve the object to stream, disk, memory, and network, and more. Remote processing uses serialization "Value" to pass objects between computers or application domains.

XML serialization is only serialized public properties and fields and does not reserve the type of assay. This is useful when you want to provide or use data without limiting the application of the application. Since XML is an open standard, it is an attractive option for sharing data through web. SOAP is also an open standard, which makes it an attractive choice.

E.g:

XML serialization can have a variety of forms, from simple to complex. For example, a class that only contains only common fields and properties, as shown in XML serialization. The following example is used to handle various advanced programs, including how to use XML serialization to generate an XML stream that meets a specific XML architecture (XSD) document.

In addition to serialization of public classes, the instance of DataSet can also be serialized, as shown in the example below:

Private void serializedataset (string filename) {

XMLSerializer Ser = New XMLSerializer (TypeOf (Dataset));

// Creates a DataSet; Adds a Table, Column, And Ten Rows.

DataSet DS = New Dataset ("MyDataSet");

DataTable T = New DataTable ("Table1");

Datacolumn C = New Datacolumn ("Thing");

t.columns.add (c);

DS.TABLES.ADD (T);

DATAROW R;

For (int i = 0; i <10; i ) {

R = T.NewRow ();

R [0] = "Thing" i;

T.ROWS.ADD (R);

}

TextWriter Writer = New StreamWriter (filename);

SER.SERIALIZE (Writer, DS);

Writer.close ();

}

It is generally used to serialize an object to be used for transmission, used in distributed processing.

Other also have applications. Just say Dottext, there are several images that use XML serialization, which can be used to formulate objects.

XML serialization converts the public field and attributes or methods of the object to the XML stream (serialized) to conform to a specific XML schema definition language (XSD) document. XML serialization produces a strong type class and converts its public attributes and fields into a sequence format for storage or transmission purposes (in this case, XML).

Since XML is an open standard, no matter what platform is used, any application can process XML streams as needed. For example, XML Web Services created with ASP.NET uses the XMLSerializer class to deliver data between the XML Web Services applications on the entire Internet or Intranet. Conversely, the reverse sequenceage acquires such an XML stream and re-constructs the object. XML serialization can also be used to sequence the object sequence to the XML stream that conforms to the SOAP specification. SOAP is an XML-based protocol that is designed to transfer process calls for use XML.

To serialize or reverse sequence, use the XMLSERIALIZER class. To create a class to serialize, use the XML schema definition tool.

To put it bluntly, it is for data universal. XML data can also cross the firewall.

Mainly the transformation of objects and streams.

After the client modifies the data, it is desirable to determine the database again; this requires the data in the database first to DataSet; this Dataset can be saved in the SESSION variable in the Server terminal, or use the viewState form to use bandwidth Server's processing power; if it is the latter, you need to transform in the DataSet and HTTP streams, requiring serialization / reverse sequence.

转载请注明原文地址:https://www.9cbs.com/read-115473.html

New Post(0)