-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest2.js
80 lines (74 loc) · 2.02 KB
/
Test2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict'
const xml = require('../xml-csharp-cereal');
// Some derived class stuff for XmlSerializer
module.exports.GetFactory = function()
{
return (new xml.XmlTemplateFactory(TestClass, AlienSuperHero, SuperHero, Person))
.addDictQuick('SerializableDictionaryOfStringPerson','Person');
}
class Person
{
constructor()
{
this.Name = null; //public string Name;
this.Age = 0; //public int Age;
}
static getXmlTemplate()
{
var temp = new xml.XmlTemplate(this);
temp.addString('Name');
temp.addInt('Age');
return temp;
}
}
class SuperHero extends Person
{
constructor()
{
super();
this.SuperName = null; // public string SuperName;
}
static getXmlTemplate()
{
var temp = super.getXmlTemplate(); // get copy of base class template
temp.extend(this); // this template should extend class
// add the addition props
temp.addString('SuperName');
return temp;
}
}
class AlienSuperHero extends SuperHero
{
constructor()
{
super();
this.Planet = null; //public string Planet;
}
static getXmlTemplate()
{
var temp = super.getXmlTemplate(); // get copy of base class template
temp.extend(this); // this template should extend class
// add the addition props
temp.addString('Planet');
return temp;
}
}
class TestClass
{
constructor()
{
this.OnePerson = null; //public Person OnePerson;
this.AnotherPerson = null; //public Person AnotherPerson;
this.SomePeople = null; //public Person[] SomePeople;
this.PhoneBook = null; //public SerializableDictionary<string, Person> PhoneBook;
}
static getXmlTemplate()
{
var temp = new xml.XmlTemplate(this);
temp.add('OnePerson','Person');
temp.add('AnotherPerson','Person');
temp.add('SomePeople','Person', 1);
temp.add('PhoneBook','SerializableDictionaryOfStringPerson');
return temp;
}
}