🗊Презентация Introduction to serialization

Нажмите для полного просмотра!
Introduction to serialization, слайд №1Introduction to serialization, слайд №2Introduction to serialization, слайд №3Introduction to serialization, слайд №4Introduction to serialization, слайд №5Introduction to serialization, слайд №6Introduction to serialization, слайд №7Introduction to serialization, слайд №8Introduction to serialization, слайд №9Introduction to serialization, слайд №10Introduction to serialization, слайд №11Introduction to serialization, слайд №12Introduction to serialization, слайд №13Introduction to serialization, слайд №14Introduction to serialization, слайд №15Introduction to serialization, слайд №16Introduction to serialization, слайд №17Introduction to serialization, слайд №18Introduction to serialization, слайд №19Introduction to serialization, слайд №20Introduction to serialization, слайд №21Introduction to serialization, слайд №22Introduction to serialization, слайд №23Introduction to serialization, слайд №24Introduction to serialization, слайд №25

Вы можете ознакомиться и скачать презентацию на тему Introduction to serialization. Доклад-сообщение содержит 25 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Introduction to Serialization
Last update: 
Lesya Klakovych
August 2016 
Reviewed by Nazar Ivchenko
Описание слайда:
Introduction to Serialization Last update: Lesya Klakovych August 2016 Reviewed by Nazar Ivchenko

Слайд 2





Agenda
Описание слайда:
Agenda

Слайд 3





What is Serialization?
Serialization is the process of transforming an object or object graph that you have in-memory into a stream of bytes or text.
Deserialization is the opposite. You take some bytes or text and transform them into an object.
Описание слайда:
What is Serialization? Serialization is the process of transforming an object or object graph that you have in-memory into a stream of bytes or text. Deserialization is the opposite. You take some bytes or text and transform them into an object.

Слайд 4





Serialization in .NET
Описание слайда:
Serialization in .NET

Слайд 5





Serialization in .NET
.NET Framework has classes (in the System.Runtime.Serialization and System.Xml.Serialization namespaces) that support:
 binary,
 XML, 
 JSON, 
 own custom serialization.
Описание слайда:
Serialization in .NET .NET Framework has classes (in the System.Runtime.Serialization and System.Xml.Serialization namespaces) that support: binary, XML, JSON, own custom serialization.

Слайд 6





Binary serialization
Описание слайда:
Binary serialization

Слайд 7





BinaryFormatter
[Serializable]
class Person {
   private int _id;
   public string FirstName;
   public string LastName;
   public void SetId(int id)
  {
     _id = id;
  }
}
Описание слайда:
BinaryFormatter [Serializable] class Person { private int _id; public string FirstName; public string LastName; public void SetId(int id) { _id = id; } }

Слайд 8





BinaryFormatter
Описание слайда:
BinaryFormatter

Слайд 9





Custom serialization. ISerializable
With a custom serialization, you can specify exactly which objects will be serialized, and how they will be serialized. 
This class must be marked with the SerializableAttribute attribute and implement the Iserializable interface . 
ISerializable interface: the Formatter calls the GetObjectData() at serialization time and populates the supplied SerializationInfo with all the data required to represent the object . For the custom deserialization, you should use a custom constructor.
Описание слайда:
Custom serialization. ISerializable With a custom serialization, you can specify exactly which objects will be serialized, and how they will be serialized. This class must be marked with the SerializableAttribute attribute and implement the Iserializable interface . ISerializable interface: the Formatter calls the GetObjectData() at serialization time and populates the supplied SerializationInfo with all the data required to represent the object . For the custom deserialization, you should use a custom constructor.

Слайд 10





ISerializable. 
Example of implementation
Описание слайда:
ISerializable. Example of implementation

Слайд 11





Custom serialization. Using attributes
 Add attribute before a custom method that manipulates the object’s data during and upon completion of serialization and deserialization.
 OnDeserializedAttribute, OnDeserializingAttribute, OnSerializedAttribute, and OnSerializingAttribute.
Описание слайда:
Custom serialization. Using attributes Add attribute before a custom method that manipulates the object’s data during and upon completion of serialization and deserialization. OnDeserializedAttribute, OnDeserializingAttribute, OnSerializedAttribute, and OnSerializingAttribute.

Слайд 12





XMLSerializer
 The XmlSerializer (namespace System.Xml.Serialization) was created with the idea of Simple Object Access Protocol (SOAP) messaging in mind. SOAP is a protocol for exchanging information with web services. It uses XML as the format for messages. XML is readable by both humans and machines, and it is independent of the environment it is used in. 
To serialize an object:
Create the object and set its public fields and properties.
Construct a XmlSerializer using the type of the object.
Call the Serialize method to generate either an XML stream or a file representation of the object's public properties and fields.
Описание слайда:
XMLSerializer The XmlSerializer (namespace System.Xml.Serialization) was created with the idea of Simple Object Access Protocol (SOAP) messaging in mind. SOAP is a protocol for exchanging information with web services. It uses XML as the format for messages. XML is readable by both humans and machines, and it is independent of the environment it is used in. To serialize an object: Create the object and set its public fields and properties. Construct a XmlSerializer using the type of the object. Call the Serialize method to generate either an XML stream or a file representation of the object's public properties and fields.

Слайд 13





XMLSerializer
To deserialize an object:
Construct a XmlSerializer using the type of the object to deserialize.
Call the Deserialize method to produce a replica of the object. After deserialization you must cast the returned object to the type of the original
Описание слайда:
XMLSerializer To deserialize an object: Construct a XmlSerializer using the type of the object to deserialize. Call the Deserialize method to produce a replica of the object. After deserialization you must cast the returned object to the type of the original

Слайд 14





XMLSerializer
You can configure how the XmlSerializer serializes your type by using attributes. These attributes are defined in the System.Xml.Serialization namespace :
 XmlIgnore - can be used to make sure that an element is not serialized
 XmlAttribute - you can map a member to an attribute on its parent node. 
 XmlElement – by default
 XmlArray - is used when serializing collections.
 XmlArrayItem - is used when serializing collections.
Описание слайда:
XMLSerializer You can configure how the XmlSerializer serializes your type by using attributes. These attributes are defined in the System.Xml.Serialization namespace : XmlIgnore - can be used to make sure that an element is not serialized XmlAttribute - you can map a member to an attribute on its parent node. XmlElement – by default XmlArray - is used when serializing collections. XmlArrayItem - is used when serializing collections.

Слайд 15





Complex and derived types serialization
Описание слайда:
Complex and derived types serialization

Слайд 16





Complex and derived types serialization
Описание слайда:
Complex and derived types serialization

Слайд 17





Using DataContract
DataContract is used when you use WCF. 
The DataContractSerializer is used by WCF to serialize your objects to XML or JSON.
You should use DataContractAttribute instead of SerializableAttribute.
 The class members are not serialized by default. You have to explicitly mark them with the DataMember attribute. 
As with binary serialization, you can use OnDeserializedAttribute, OnDeserializingAttribute, OnSerializedAttribute, and OnSerializingAttribute to configure the four phases of the serialization and deserialization process.
Описание слайда:
Using DataContract DataContract is used when you use WCF. The DataContractSerializer is used by WCF to serialize your objects to XML or JSON. You should use DataContractAttribute instead of SerializableAttribute. The class members are not serialized by default. You have to explicitly mark them with the DataMember attribute. As with binary serialization, you can use OnDeserializedAttribute, OnDeserializingAttribute, OnSerializedAttribute, and OnSerializingAttribute to configure the four phases of the serialization and deserialization process.

Слайд 18





Using DataContract
Описание слайда:
Using DataContract

Слайд 19





Using DataContract
Описание слайда:
Using DataContract

Слайд 20





NetDataContractSerializer
Описание слайда:
NetDataContractSerializer

Слайд 21





JSON Serialization

We can use DataContractJsonSerializer to serialize type instance to JSON string and deserialize JSON string to type instance
DataContractJsonSerializer is under System.Runtime.Serialization.Json namespace. 
It is included in System.ServiceModel.Web.dll in .NET Framework 3.5 and System.Runtime.Serialization in .NET Framework 4.0. We need to add it as reference
http://www.codeproject.com/Articles/272335/JSON-Serialization-and-Deserialization-in-ASP-NET#
Описание слайда:
JSON Serialization We can use DataContractJsonSerializer to serialize type instance to JSON string and deserialize JSON string to type instance DataContractJsonSerializer is under System.Runtime.Serialization.Json namespace. It is included in System.ServiceModel.Web.dll in .NET Framework 3.5 and System.Runtime.Serialization in .NET Framework 4.0. We need to add it as reference http://www.codeproject.com/Articles/272335/JSON-Serialization-and-Deserialization-in-ASP-NET#

Слайд 22





Demonstration 4. 
Json Serialization. class Person
Описание слайда:
Demonstration 4. Json Serialization. class Person

Слайд 23





Demonstration 4. 
Json Deserialization. class Person
Описание слайда:
Demonstration 4. Json Deserialization. class Person

Слайд 24





JSON Brief Introduction
JSON (JavaScript Object Notation) is one lightweight data exchange format. 
JSON is "name/value" assembly. Its structure is made up with {}, [], comma, colon and double quotation marks. And it includes the following data types: Object, Number, Boolean, String, Array, NULL. 
JSON has three styles: 
1. Object: An unordered "name/value" assembly. An object begins with "{" and ends with "}". Behind each "name", there is a colon. And comma is used to separate much "name/value". For example: 
2. Array: Value order set. An array begins with "[" and end with "]". And values are separated with comma. For example: 
3. String: Any quantity unicode character assembly which is enclosed with quotation marks. It uses backslash to escape.
Описание слайда:
JSON Brief Introduction JSON (JavaScript Object Notation) is one lightweight data exchange format. JSON is "name/value" assembly. Its structure is made up with {}, [], comma, colon and double quotation marks. And it includes the following data types: Object, Number, Boolean, String, Array, NULL. JSON has three styles: 1. Object: An unordered "name/value" assembly. An object begins with "{" and ends with "}". Behind each "name", there is a colon. And comma is used to separate much "name/value". For example: 2. Array: Value order set. An array begins with "[" and end with "]". And values are separated with comma. For example: 3. String: Any quantity unicode character assembly which is enclosed with quotation marks. It uses backslash to escape.

Слайд 25





Questions?
Описание слайда:
Questions?



Похожие презентации
Mypresentation.ru
Загрузить презентацию