annotate api/Factories/Xml/Zip/StringZipEntrySource.cs @ 226:c931684f9024

Re #234: Invalid data file doesn't stop load * Add internal methods to remove game systems or races that fail to load * Add error handling on XML CompleteLoading so that game system or race is removed, but make sure not to affect error
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Dec 2009 15:40:50 +0000
parents b04512847424
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
127
b04512847424 * Fix licensing error highlighted by Ohloh analysis
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
1 // This file (StringZipEntrySource.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
105
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
127
b04512847424 * Fix licensing error highlighted by Ohloh analysis
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
3 // The library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
b04512847424 * Fix licensing error highlighted by Ohloh analysis
IBBoard <dev@ibboard.co.uk>
parents: 105
diff changeset
4
105
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System;
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.IO;
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.Lang;
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using ICSharpCode.SharpZipLib.Zip;
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 namespace IBBoard.WarFoundry.API.Factories.Xml.Zip
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 /// <summary>
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 /// A simple implementation of IStaticDataSource that lets us add a string directly to a Zip file
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 /// </summary>
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public class StringZipEntrySource : IStaticDataSource
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private byte[] entryContent;
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 public StringZipEntrySource(String content)
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 entryContent = StringManipulation.StringToBytes(content);
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 }
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public Stream GetSource()
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 return new MemoryStream(entryContent);
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 }
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 }
f5aec697b8ea Re #53: Make WarFoundry XML saver
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 }