Advanced .NET Programming II 6th Lecture

Slides:



Advertisements
Similar presentations
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Advertisements

CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
INHERITANCE BASICS Reusability is achieved by INHERITANCE
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 2 nd Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 4 th Lecture Pavel Ježek
.Net Remoting Pooja Panjala 06/17/10. Agenda What is.net Remoting? Explanation of terms Architecture Implementation of Remoting Sample example.net Security.
Object Oriented Programming Files and Streams Dr. Mike Spann
C# - Files and Streams Outline Files and Streams Classes File and Directory Creating a Sequential-Access File Reading Data from a Sequential-Access.
Serialization objects created in a program reside in RAM through references object o; heap stack content.
1 Advanced Programming Topics - II Objectives:  Background  Remoting  Types of remoting  Marshalling  Farmatters  Channels.
History, Architecture, and Implementation of the CLR Serialization and Formatter Classes Peter de Jong April 24, 2003.
Windows Programming Using C# Windows Services, Serialization, and Isolated Storage.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 7 th & 8 th Lecture Pavel Ježek.
1 Binary Files ผศ. ดร. หมัดอามีน หมันหลิน Faculty of IST, MUT
Advanced .NET Programming I 13th Lecture
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 11 th Lecture Pavel Ježek
HeuristicLab. Motivation  less memory pressure no DOM single pass linear process  less developer effort no interfaces to implement  modularity & flexibility.
Serialization  What is Serialization?  System.Serialization  Scenarios in Serialization  Basic Serialization  Custom Serialization.
Serialization What is Serialization Serialization is the process of converting an object, or a connected graph of objects, stored within computer memory,
Lecture 19 Serialization Richard Gesick. Serialization Sometimes it is easier to read or write entire objects than to read and write individual fields.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 10 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 8 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 11 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 9 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 2 nd Lecture Pavel Ježek
Input and Output 23: Input and Output
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 4 th Lecture Pavel Ježek
- This slide is intentionally left blank - Some of the slides are based on University of Linz.NET presentations. © University of Linz, Institute for System.
.NET XML Web Services by Joe Mayo Mayo Software Consulting
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 7 th Lecture Pavel Ježek
1 Statements © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming II 5 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming II 3 rd Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 7 th Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming II 2 nd Lecture Pavel Ježek
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 2 nd Lecture Pavel Ježek
OBJECT ORIENTED PROGRAMMING II LECTURE 21 GEORGE KOUTSOGIANNAKIS
Advanced .NET Programming I 11th Lecture
Advanced .NET Programming I 2nd Lecture
Examples of Classes & Objects
Input and Output 23: Input and Output
Advanced .NET Programming II 4th Lecture
Advanced .NET Programming II 10th Lecture
Advanced .NET Programming I 8th Lecture
Advanced .NET Programming I 4th Lecture
Advanced .NET Programming I 7th Lecture
Serialization.
Advanced .NET Programming I 6th Lecture
Classes & Objects: Examples
Sampath Kumar S Assistant Professor, SECE
Object Oriented Programming
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Quiz Points 3 Rules Raise your hand if you know the question
Advanced .NET Programming I 13th Lecture
Advanced .NET Programming I 9th Lecture
Advanced .NET Programming I 8th Lecture
Advanced .NET Programming I 5th Lecture
C# Language & .NET Platform 10th Lecture
Advanced .NET Programming I 7th Lecture
- This slide is intentionally left blank -
Advanced .NET Programming I 3rd Lecture
Advanced .NET Programming I 4th Lecture
C# Language & .NET Platform 11th Lecture
Advanced .NET Programming I 6th Lecture
C# Language & .NET Platform 3rd Lecture
C# Language & .NET Platform 9th Lecture
C# Language & .NET Platform 4th Lecture
C# Language & .NET Platform 8th Lecture
C# Language & .NET Platform 12th Lecture
Presentation transcript:

Advanced .NET Programming II 6th Lecture Pavel Ježek pavel.jezek@d3s.mff.cuni.cz Some of the slides are based on University of Linz .NET presentations. © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License (http://www.msdnaa.net/curriculum/license_curriculum.aspx)

Serialization

System.Runtime.Serialization Serialization and Formatters namespace System.Runtime.Serialization.Formatters.Binary BinaryFormatter namespace System.Runtime.Serialization.Formatters.Soap assembly System.Runtime.Serialization.Formatters.Soap SoapFormatter Serializable objects: Must have SerializableAttribute defined All public and private member fields are serialized – this implies that all of them must be serializable, i.e. have SerializableAttribute defined Fields with NonSerializedAttribute are excluded from default serialization Can implement ISerializable interface to provide their custom serialization public interface IFormatter { void Serialize(Stream serializationStream, object graph); object Deserialize(Stream serializationStream); … }

Example: Serialization [Serializable] public class TestSimpleObject { int member1; string member2; string member3; double member4; [NonSerialized] string member5; public TestSimpleObject() member1 = 11; member2 = "hello"; member3 = "hello"; member4 = 3.14159265; member5 = "hello world!"; } [OnDeserializing] public void SetDefaults(StreamingContext ctx) { member5 = "DefaultValue"; public void Print() Console.WriteLine("member1 = '{0}'", member1); Console.WriteLine("member2 = '{0}'", member2); Console.WriteLine("member3 = '{0}'", member3); Console.WriteLine("member4 = '{0}'", member4); Console.WriteLine("member5 = '{0}'", member5);

Example: Serialization, cont. using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Soap; public class Test { public static void Main() TestSimpleObject obj = new TestSimpleObject(); obj.Print(); Stream stream = File.Open("data.xml", FileMode.Create); SoapFormatter formatter = new SoapFormatter(); formatter.Serialize(stream, obj); stream.Close(); obj = null; // stream = File.Open("data.xml", FileMode.Open); obj = (TestSimpleObject) formatter.Deserialize(stream); }

Example: Serialization, cont. Output of SoapFormatter: <SOAP-ENV:Envelope …> <SOAP-ENV:Body> <a1:TestSimpleObject id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/assem/Remoting1%2C%20Version%3D1.0.1256.35476%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull"> <member1>11</member1> <member2 id="ref-3">hello</member2> <member3 href="#ref-3"/> <member4>3.14159265</member4> </a1:TestSimpleObject> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Output of BinaryFormatter: