comparison api/Factories/AbstractNativeWarFoundryFactory.cs @ 313:f00a57369aaa

Re #253: Allow multiple data files in a single zip * Add event-based mechanism to allow GameSystem to be registered before Race is loaded from a single zip
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Feb 2011 15:54:13 +0000
parents 3854c26073c4
children
comparison
equal deleted inserted replaced
312:3854c26073c4 313:f00a57369aaa
80 80
81 try 81 try
82 { 82 {
83 if (CheckCanFindSystemFileContent(file)) 83 if (CheckCanFindSystemFileContent(file))
84 { 84 {
85 AddAll(objects, CreateGameSystemsFromFile(file)); 85 foreach (GameSystem system in CreateGameSystemsFromFile(file))
86 {
87 OnGameSystemLoaded(system);
88 objects.Add(system);
89 }
86 } 90 }
91
87 if (CheckCanFindRaceFileContent(file)) 92 if (CheckCanFindRaceFileContent(file))
88 { 93 {
89 AddAll(objects, CreateRacesFromFile(file)); 94 foreach(Race race in CreateRacesFromFile(file))
95 {
96 OnRaceLoaded(race);
97 objects.Add(race);
98 }
90 } 99 }
100
91 if (CheckCanFindArmyFileContent(file)) 101 if (CheckCanFindArmyFileContent(file))
92 { 102 {
93 AddAll(objects, CreateArmiesFromFile(file)); 103 foreach (Army army in CreateArmiesFromFile(file))
104 {
105 OnArmyLoaded(army);
106 objects.Add(army);
107 }
94 } 108 }
95 } 109 }
96 finally 110 finally
97 { 111 {
98 file.Close(); 112 file.Close();
99 } 113 }
100 114
101 return objects; 115 return objects;
102 }
103
104 private void AddAll <NEW_ITEM_TYPE>(ICollection<IWarFoundryObject> collection, ICollection<NEW_ITEM_TYPE> newItems) where NEW_ITEM_TYPE : IWarFoundryObject
105 {
106 foreach (IWarFoundryObject obj in newItems)
107 {
108 collection.Add(obj);
109 }
110 } 116 }
111 117
112 protected ICollection<Army> CreateArmiesFromFile(ZipFile file) 118 protected ICollection<Army> CreateArmiesFromFile(ZipFile file)
113 { 119 {
114 ICollection<ZipEntry> dataStreams = GetArmyZipEntries(file); 120 ICollection<ZipEntry> dataStreams = GetArmyZipEntries(file);