public static DxfFile Load(Stream stream, Encoding defaultEncoding) { int readBytes; var firstLine = GetFirstLine(stream, defaultEncoding, out readBytes); var reader = new BinaryReader(stream); // check for binary sentinels DxfFile file; if (firstLine == DxbReader.BinarySentinel) { file = new DxbReader().ReadFile(reader); } else { var dxfReader = GetCodePairReader(firstLine, readBytes, reader, defaultEncoding); file = LoadFromReader(dxfReader); } return(file); }
public static DxfFile Load(Stream stream) { var reader = new BinaryReader(stream); int readBytes; var firstLine = GetFirstLine(reader, out readBytes); // check for binary sentinels DxfFile file; if (firstLine == DxbReader.BinarySentinel) { file = new DxbReader().ReadFile(reader); } else { var dxfReader = GetCodePairReader(firstLine, readBytes, reader); file = LoadFromReader(dxfReader); } return file; }
public static DxfFile Load(Stream stream) { var reader = new BinaryReader(stream); // read first line char-by-char var sb = new StringBuilder(); char c = reader.ReadChar(); while (c != '\n') { sb.Append(c); c = reader.ReadChar(); } // trim BOM var line = sb.ToString().TrimEnd('\r'); if (line.Length > 0 && line[0] == 0xFEFF) { line = line.Substring(1); } // check for binary sentinels DxfFile file; if (line == DxbReader.BinarySentinel) { file = new DxbReader().ReadFile(reader); } else { IDxfCodePairReader dxfReader; if (line == BinarySentinel) { dxfReader = new DxfBinaryReader(reader); } else { dxfReader = new DxfAsciiReader(stream, line); } file = LoadFromReader(dxfReader); } return file; }