source: branches/New Persistence Exploration/Persistence/Persistence/SerializationTest.cs @ 1248

Last change on this file since 1248 was 1248, checked in by epitzer, 11 years ago

Evaluation of .NET native serialization. (#506)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml.Serialization;
5using System.Collections;
6
7namespace Persistence {
8
9  [Serializable]
10  public class Employer {
11
12    public string name;
13    public ArrayList employees;
14
15    public Employer() { }
16
17    public Employer(string name) {
18      this.name = name;
19      this.employees = new ArrayList();
20    }
21
22  }
23
24  [Serializable]
25  public class Employee {
26
27    public string firstName;
28    public string lastName;
29    public Employer employer;
30
31    public Employee() { }
32
33    public Employee(string firstName, string lastName, Employer employer) {
34      this.firstName = firstName;
35      this.lastName = lastName;
36      this.employer = employer;
37    }
38
39  }
40   
41  class SerializationTest {
42    public static void Main() {
43
44      Employer company = new Employer("FH OOE F&E GmbH.");
45      company.employees.Add(new Employee("John", "Smith", company));
46      company.employees.Add(new Employee("Max", "Mustermann", company));
47      company.employees.Add(new Employee("Erik", "Pitzer", company));
48
49      XmlSerializer s = new XmlSerializer(typeof(Employer));
50      s.Serialize(Console.Out, company);
51      Console.ReadLine();
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.