File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 5
5
using System . Collections . Generic ;
6
6
using System . Xml . Linq ;
7
7
using System . Globalization ;
8
+ using System . IO ;
8
9
9
10
namespace TiledSharp
10
11
{
@@ -31,9 +32,22 @@ public class TmxMap : TmxDocument
31
32
32
33
public TmxMap ( string filename )
33
34
{
34
- XDocument xDoc = ReadXml ( filename ) ;
35
- var xMap = xDoc . Element ( "map" ) ;
35
+ Load ( ReadXml ( filename ) ) ;
36
+ }
37
+
38
+ public TmxMap ( Stream inputStream )
39
+ {
40
+ Load ( XDocument . Load ( inputStream ) ) ;
41
+ }
36
42
43
+ public TmxMap ( XDocument xDoc )
44
+ {
45
+ Load ( xDoc ) ;
46
+ }
47
+
48
+ private void Load ( XDocument xDoc )
49
+ {
50
+ var xMap = xDoc . Element ( "map" ) ;
37
51
Version = ( string ) xMap . Attribute ( "version" ) ;
38
52
39
53
Width = ( int ) xMap . Attribute ( "width" ) ;
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ public class TmxDocument
18
18
{
19
19
public string TmxDirectory { get ; private set ; }
20
20
21
+ public TmxDocument ( )
22
+ {
23
+ TmxDirectory = string . Empty ;
24
+ }
25
+
21
26
protected XDocument ReadXml ( string filepath )
22
27
{
23
28
XDocument xDoc ;
You can’t perform that action at this time.
0 commit comments