Session 5

404 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
404
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Session 5

  1. 1. Session 5 .NET Serialization
  2. 2. Session Objectives <ul><li>Discuss Object serialization </li></ul><ul><li>Discuss serialization of objects to streams </li></ul><ul><li>Discuss Binary formatters </li></ul><ul><li>Discuss SOAP formatters </li></ul>
  3. 3. Object Serialisation(1) <ul><li>Serializing objects to a stream using binary formatters </li></ul><ul><li>Serializing objects to a stream using SOAP formatters and saving them as XML files </li></ul>
  4. 4. Object Serialization(2) <ul><li>Objects may be remoted by serializing an object to a stream of bytes </li></ul><ul><li>This stream is then transmitted to another machine that understands the serialization format </li></ul>
  5. 5. How .NET serialization works ? <ul><li>.NET formatter class must be used to control the serialization of the object to and from the stream </li></ul><ul><li>The serialized stream carries information about the objects type, including its assembly name, culture & version </li></ul>
  6. 6. Role of formatters <ul><li>Determines the serialization format for objects </li></ul><ul><li>All formatters expose an interface called the IFormatter interface </li></ul>
  7. 7. IFormatter Interface <ul><li>The 2 formatters that inherit from the IFormatter interface are - </li></ul><ul><li>BinaryFormatter </li></ul><ul><li>SOAPFormatter </li></ul>
  8. 8. Binary formatter <ul><li>To serialize an object we need - </li></ul><ul><li>The object that is to be serialized </li></ul><ul><li>A stream to hold the serialized object </li></ul><ul><li>A formatter which is used to serialize objects </li></ul>
  9. 9. Serializing an object using Binary formatter <ul><li>Example 1 - </li></ul>
  10. 10. Serializing an object using Binary formatter <ul><li>Example 2 - </li></ul>
  11. 11. Deserializing an object using Binary formatter <ul><li>Example 3 - </li></ul>
  12. 12. Deserializing an object using Binary formatter <ul><li>Output - </li></ul>
  13. 13. Serializing an object using SOAP formatter <ul><li>Example 4 - </li></ul>
  14. 14. Serializing an object using SOAP formatter <ul><li>Output - </li></ul>
  15. 15. Deserializing an object using SOAP formatter <ul><li>Example 5 - </li></ul>
  16. 16. Deserializing an object using SOAP formatter <ul><li>Output - </li></ul>
  17. 17. Selectively serializing the members of an object <ul><li>Example 6 - </li></ul>

×