annotate api/Factories/Xml/Zip/StringZipEntrySource.cs @ 128:45a9452579a2

Fixes #50: Complete core loading of WarFoundry XML files * Add exceptions on invalid data - completes WarFoundry 0.1 loading needs
author IBBoard <dev@ibboard.co.uk>
date Wed, 26 Aug 2009 18:37:55 +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 }