Exemple #1
0
 public HexFile BuildHexFile()
 {
     var hexFile = new HexFile();
     WriteTo(hexFile);
     hexFile.Lines.Add(new HexFileLine { Type = HexFileLineType.Eof });
     return hexFile;
 }
Exemple #2
0
 public HexFile Build()
 {
     FlushLine();
     _hf.Lines.Add(new HexFileLine {
         Type = HexFileLineType.Eof
     });
     var res = _hf;
     _hf = new HexFile();
     _offset = 0;
     return res;
 }
Exemple #3
0
 public static HexFile Parse(TextReader reader)
 {
     var res = new HexFile();
     var lineNumber = 1;
     try {
         while (reader.Peek() != -1) {
             var rawLine = reader.ReadLine();
             if (!string.IsNullOrWhiteSpace(rawLine)) {
                 var line = HexFileLine.Parse(rawLine);
                 res.Lines.Add(line);
             }
             lineNumber++;
         }
     } catch (Exception e) {
         throw new HexFileException("couldn't parse line " + lineNumber + ". " + e.Message);
     }
     return res;
 }
Exemple #4
0
 public void WriteTo(HexFile hexFile)
 {
     var lines = (Content.Count + 15) / 16;
     for (var i = 0; i < lines; i++) {
         var adr = i * 16;
         var line = new HexFileLine {
             Address = (ushort)adr,
             Type = HexFileLineType.Data,
             Data = Content.Skip(adr).Take(16).ToArray()
         };
         hexFile.Lines.Add(line);
     }
 }