Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Objects/WarFoundryObject.cs @ 8:613bc5eaac59
Re #9 - Make WarFoundry loading granular
* Remove specific staged loading classes
* Rework category loading for GameSystem and Race to make it use AddCategory(Category) method
* Promote staged loading from Native Factory to all Factories level
* Refactor XML Factory to use smaller methods
Also removed some commented code that isn't used any more
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 19:24:13 +0000 |
parents | 520818033bb6 |
children | 306558904c2a |
rev | line source |
---|---|
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1 using System; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
2 using IBBoard.WarFoundry.API.Factories; |
0 | 3 |
4 namespace IBBoard.WarFoundry.API.Objects | |
5 { | |
6 /// <summary> | |
7 /// Summary description for WarFoundryObject. | |
8 /// </summary> | |
9 public abstract class WarFoundryObject : IWarFoundryObject | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
10 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
11 protected string id; |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
12 protected string name; |
0 | 13 public event StringValChangedDelegate NameChanged; |
14 | |
8
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
15 protected WarFoundryObject() |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
16 { |
613bc5eaac59
Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
17 } |
0 | 18 |
19 protected WarFoundryObject(string objName) : this() | |
20 { | |
21 Name = objName; | |
22 } | |
23 | |
24 protected WarFoundryObject(string objId, string objName) : this(objName) | |
25 { | |
26 ID = objId; | |
27 } | |
28 | |
29 public virtual string ID | |
30 { | |
31 get | |
32 { | |
33 if (id == null) | |
34 { | |
35 id = GenerateID(); | |
36 } | |
37 | |
38 return id; | |
39 } | |
40 | |
41 set { id = (value == null ? GenerateID() : value.Trim()); } | |
42 } | |
43 | |
44 public virtual string Name | |
45 { | |
46 get | |
47 { | |
48 if (HasDefaultName()) | |
49 { | |
50 return DefaultName(); | |
51 } | |
52 else | |
53 { | |
54 return name; | |
55 } | |
56 } | |
57 set | |
58 { | |
59 string oldValue = name; | |
60 name = value; | |
61 | |
62 if (name!=oldValue) | |
63 { | |
64 OnNameChanged(oldValue, name); | |
65 } | |
66 } | |
67 } | |
68 | |
69 protected bool HasDefaultName() | |
70 { | |
71 return (name == null || name == ""); | |
72 } | |
73 | |
74 protected void OnNameChanged(string oldValue, string newValue) | |
75 { | |
76 if (NameChanged!=null) | |
77 { | |
78 NameChanged(this, oldValue, newValue); | |
79 } | |
80 } | |
81 | |
82 protected virtual string DefaultName() | |
83 { | |
84 return "-"; | |
85 } | |
86 | |
87 protected string GenerateID() | |
88 { | |
89 return "ID" + UnixTimestamp.GetTimestamp(DateTime.Now) + "." + DateTime.Now.Millisecond; | |
90 } | |
91 } | |
92 } |