protected virtual int MatchAlignment(long offset, BuildBytesInfo info) { int count = 0; // match alignment // find lower alignment offset long lowAlign = (offset / alignment) * alignment; // fill with blanks (eg "__ __") for (long i = lowAlign; i < offset; i++) { if (i != lowAlign) { BuildSeparator(info.Separator); } BuildByte(null, 0, info, true); count++; } // if alignment adjustments had to be made // emit one more separator (eg "__ __ " <-- notice last space) if (lowAlign != offset) { writer.Write(info.Separator); } return(count); }
protected override int BuildByte(IBuffer buf, long offset, BuildBytesInfo info, bool dummy) { if (offset % 2 == 0) BuildString("<span style=\"color:blue\">"); int n = base.BuildByte(buf, offset, info, dummy); if (offset % 2 == 0) BuildString("</span>"); return n; }
public virtual int BuildBytes(IBuffer buffer, long offset, BuildBytesInfo info) { int nwritten = 0; int count = info.Count; count -= MatchAlignment(offset, info); // emit the bytes (eg "__ __ 00 00") for (int i = 0; i < count; i++) { if (i != 0) BuildSeparator(info.Separator); nwritten += BuildByte(buffer, offset + i, info, false); } writer.Flush(); return nwritten; }
protected virtual int BuildByte(IBuffer buffer, long offset, BuildBytesInfo info, bool dummy) { string str; int nwritten = 0; byte b = 0; if (dummy == true || offset >= buffer.Size) { dummy = true; } else { nwritten++; b = buffer[offset]; } if (info.Type == 'A') str = info.Type.ToString(); else { bool lowercase; int numBase = GetBaseFromArgument(info.Type, out lowercase); str = BaseConverter.ConvertToString(b, numBase, false, lowercase, 0); } if (!dummy && info.Prefix != null) BuildPrefix(info.Prefix); else BuildEmpty(info.Prefix, " "); if (!dummy && str != null) { BuildByteData(str); } else if (info.Empty != null) BuildEmpty(str, info.Empty); else BuildEmpty(str, " "); if (!dummy && info.Suffix != null) BuildSuffix(info.Suffix); else BuildEmpty(info.Suffix, " "); return nwritten; }
protected virtual int BuildByte(IBuffer buffer, long offset, BuildBytesInfo info, bool dummy) { string str; int nwritten = 0; byte b = 0; if (dummy == true || offset >= buffer.Size) { dummy = true; } else { nwritten++; b = buffer[offset]; } if (info.Type == 'A') { // Replace unprintable characters with dots if (b < 32 || b >= 127) { str = "."; } else { str = System.Text.Encoding.ASCII.GetString(new byte[] { b }); } } else { bool lowercase; int numBase = GetBaseFromArgument(info.Type, out lowercase); str = BaseConverter.ConvertToString(b, numBase, false, lowercase, 0); } if (!dummy && info.Prefix != null) { BuildPrefix(info.Prefix); } else { BuildEmpty(info.Prefix, " "); } if (!dummy && str != null) { BuildByteData(str); } else if (info.Empty != null) { BuildEmpty(str, info.Empty); } else { BuildEmpty(str, " "); } if (!dummy && info.Suffix != null) { BuildSuffix(info.Suffix); } else { BuildEmpty(info.Suffix, " "); } return(nwritten); }