Mercurial > repos > IBBoard.WarFoundry.API.Tests
annotate API/EventListeningWarFoundryLoader.cs @ 89:90dee8d781ee
Re #253: Allow multiple data files in a single zip
* Add and use loader that just listens to events to capture new objects and does nothing else
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 27 Feb 2011 19:44:08 +0000 |
parents | |
children | 5d19fee8e9dc |
rev | line source |
---|---|
89
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 using System; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 using IBBoard.WarFoundry.API.Factories; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 using System.Collections.Generic; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 using IBBoard.WarFoundry.API.Objects; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 namespace IBBoard.WarFoundry.API |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 public class EventListeningWarFoundryLoader : AbstractWarFoundryLoader |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 private IDictionary<string, GameSystem> gameSystems; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 private IDictionary<string, Race> races; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 private IDictionary<string, Army> armies; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public EventListeningWarFoundryLoader() |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 gameSystems = new Dictionary<string, GameSystem>(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 races = new Dictionary<string, Race>(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 armies = new Dictionary<string, Army>(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 public override void RegisterFactory (INativeWarFoundryFactory factory) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 base.RegisterFactory (factory); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 factory.GameSystemLoaded+= DoStoreGameSystem; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 factory.RaceLoaded+= DoStoreRace; |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 protected override GameSystem GetExistingSystemForSystem (GameSystem system) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 throw new System.NotImplementedException(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 protected override void DoStoreGameSystem (GameSystem system) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 gameSystems.Add(system.ID, system); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 protected override void DoStoreRace (Race race) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 races.Add(race.ID, race); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 public override GameSystem[] GetGameSystems () |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 throw new System.NotImplementedException(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 public override GameSystem GetGameSystem (string systemID) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 return DictionaryUtils.GetValue(gameSystems, systemID); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 protected override void RemoveGameSystem (GameSystem system) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 throw new System.NotImplementedException(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 public override Race[] GetRaces (GameSystem system) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 throw new System.NotImplementedException(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 public override Race GetRace (GameSystem system, string raceID) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 return GetRace(system, raceID, ""); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 public override Race GetRace (GameSystem system, string raceID, string raceSubID) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 return DictionaryUtils.GetValue(races, raceID); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 protected override void RemoveRace (Race race) |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 { |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 throw new System.NotImplementedException(); |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 } |
90dee8d781ee
Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 } |