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