1: using System.Collections.Generic;
2:
3: /// <summary>
4: /// Test class for ToXML extension
5: /// </summary>
6: public class Person
7: {
8: #region Constructors
9:
10: /// <summary>
11: /// Default constructor, need to serialize objects
12: /// </summary>
13: public Person()
14: {
15: }
16: public Person(string firstName, string secondName)
17: {
18: this.firstName = firstName;
19: this.secondName = secondName;
20: }
21:
22: #endregion
23:
24: #region Fields and Properties
25:
26: private string firstName;
27: public string FirstName
28: {
29: get
30: {
31: return firstName;
32: }
33: set
34: {
35: firstName = value;
36: }
37: }
38: private string secondName;
39: public string SecondName
40: {
41: get
42: {
43: return secondName;
44: }
45: set
46: {
47: secondName = value;
48: }
49: }
50: private List<Person> childrens;
51: public List<Person> Childrens
52: {
53: get
54: {
55: if (childrens == null)
56: {
57: childrens = new List<Person>();
58: }
59: return childrens;
60: }
61: set
62: {
63: childrens = value;
64: }
65: }
66:
67: #endregion
68:
69: #region Methods
70:
71: /// <summary>
72: /// Add a children creating a new Person with parameters
73: /// </summary>
74: /// <param name="f">first name of the children</param>
75: /// <param name="s">second name of the children</param>
76: public void AddChildren(string f, string s)
77: {
78: this.Childrens.Add(new Person(f, s));
79: }
80: /// <summary>
81: /// Add a children creating a new Person with parameters plus current SecondName
82: /// </summary>
83: /// <param name="f">first name of the children</param>
84: public void AddChildren(string f)
85: {
86: this.Childrens.Add(new Person(f, this.SecondName));
87: }
88:
89: #endregion
90:
91: }