public WorldFile(string fileName, IList <TokenID> allowedTokens) { try { if (string.IsNullOrEmpty(fileName)) { throw new InvalidDataException($"Empty filename could not be parsed for for X and Z tile information."); } // Parse the tile location out of the filename. int p = fileName.LastIndexOf("\\WORLD\\W", StringComparison.OrdinalIgnoreCase); if (!int.TryParse(fileName.AsSpan(p + 8, 7), out int tileX) || !int.TryParse(fileName.AsSpan(p + 15, 7), out int tileZ)) { throw new InvalidDataException($"Could not parse filename {fileName} for X and Z tile information."); } TileX = tileX; TileZ = tileZ; using (SBR sbr = SBR.Open(fileName)) { using (SBR block = sbr.ReadSubBlock()) { Objects = new WorldObjects(block, allowedTokens, TileX, TileZ); } // some w files have additional comments at the end // eg _Skip ( "TS DB-Utility - Version: 3.4.05(13.10.2009), Filetype='World', Copyright (C) 2003-2009 by ...CarlosHR..." ) sbr.Skip(); } } catch (Exception error) { throw new FileLoadException(fileName, error); } }
/// <summary> /// constructor /// </summary> /// <param name="filename">file to read and parse</param> public MstsShapeFile(string filename) { var file = SBR.Open(filename); shape = new MstsShape(file.ReadSubBlock()); file.VerifyEndOfBlock(); }
public WorldFile(string fileName, List <TokenID> allowedTokens) { try { // Parse the tile location out of the filename. var p = fileName.LastIndexOf("\\WORLD\\W", StringComparison.OrdinalIgnoreCase); TileX = int.Parse(fileName.Substring(p + 8, 7)); TileZ = int.Parse(fileName.Substring(p + 15, 7)); using (var sbr = SBR.Open(fileName)) { using (var block = sbr.ReadSubBlock()) { Objects = new WorldObjects(block, allowedTokens, TileX, TileZ); } // some w files have additional comments at the end // eg _Skip ( "TS DB-Utility - Version: 3.4.05(13.10.2009), Filetype='World', Copyright (C) 2003-2009 by ...CarlosHR..." ) sbr.Skip(); } } catch (Exception error) { throw new FileLoadException(fileName, error); } }
public ShapeFile(string fileName, bool suppressShapeWarnings) { var file = SBR.Open(fileName); Shape = new Shape(file.ReadSubBlock()); file.VerifyEndOfBlock(); if (!suppressShapeWarnings) { Validate(fileName); } }
public ShapeFile(string fileName, bool suppressShapeWarnings) { using (SBR file = SBR.Open(fileName)) { Shape = new Shape(file.ReadSubBlock()); // file.VerifyEndOfBlock();//covered through "using" Dispose-implementation if (!suppressShapeWarnings) { Validate(fileName); } } }
public void InsertORSpecificData(string fileName) { using (SBR sbr = SBR.Open(fileName)) { using (SBR block = sbr.ReadSubBlock()) { Objects.InsertORSpecificData(block); } // some w files have additional comments at the end // eg _Skip ( "TS DB-Utility - Version: 3.4.05(13.10.2009), Filetype='World', Copyright (C) 2003-2009 by ...CarlosHR..." ) sbr.Skip(); } }
public TerrainFile(string fileName) { using (var sbr = SBR.Open(fileName)) using (var block = sbr.ReadSubBlock()) Terrain = new Terrain(block); }