本文整理汇总了C#中HexSpan.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# HexSpan.Contains方法的具体用法?C# HexSpan.Contains怎么用?C# HexSpan.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HexSpan
的用法示例。
在下文中一共展示了HexSpan.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteAscii
HexCell[] WriteAscii(HexBytes hexBytes, HexSpan visibleBytesSpan, out VST.Span fullSpan, out VST.Span visibleSpan) {
Debug.Assert(showAscii);
cellList.Clear();
int fullStart = CurrentTextIndex;
int? visStart = null;
int? visEnd = null;
var pos = visibleBytesSpan.Start;
int cellPos = 0;
for (ulong i = 0; i < bytesPerLine; i++, pos++) {
int groupIndex = (cellPos / groupSizeInBytes) & 1;
HexBufferSpan bufferSpan;
int cellStart = CurrentTextIndex;
if (visibleBytesSpan.Contains(pos)) {
if (visStart == null)
visStart = CurrentTextIndex;
long index = (long)(pos - visibleBytesSpan.Start).ToUInt64();
int b = hexBytes.TryReadByte(index);
if (b < 0)
stringBuilder.Append('?');
else if (b < 0x20 || b > 0x7E)
stringBuilder.Append('.');
else
stringBuilder.Append((char)b);
bufferSpan = new HexBufferSpan(buffer, new HexSpan(pos, 1));
}
else {
if (visStart != null && visEnd == null)
visEnd = CurrentTextIndex;
stringBuilder.Append(' ');
bufferSpan = default(HexBufferSpan);
}
var cellSpan = VST.Span.FromBounds(cellStart, CurrentTextIndex);
var separatorSpan = new VST.Span(cellSpan.End, 0);
cellList.Add(new HexCell((int)i, groupIndex, bufferSpan, cellSpan, cellSpan, separatorSpan, cellSpan));
cellPos++;
}
if ((ulong)fullStart + bytesPerLine != (ulong)CurrentTextIndex)
throw new InvalidOperationException();
if (visStart != null && visEnd == null)
visEnd = CurrentTextIndex;
visibleSpan = visStart == null ? default(VST.Span) : VST.Span.FromBounds(visStart.Value, visEnd.Value);
fullSpan = VST.Span.FromBounds(fullStart, CurrentTextIndex);
if (AsciiSpan != fullSpan)
throw new InvalidOperationException();
return cellList.ToArray();
}
示例2: WriteValues
HexCell[] WriteValues(HexBytes hexBytes, HexSpan visibleBytesSpan, out VST.Span fullSpan, out VST.Span visibleSpan) {
Debug.Assert(showValues);
cellList.Clear();
int fullStart = CurrentTextIndex;
ulong cellCount = bytesPerLine / (ulong)valueFormatter.ByteCount;
var flags = valuesLowerCaseHex ? HexValueFormatterFlags.LowerCaseHex : HexValueFormatterFlags.None;
var pos = visibleBytesSpan.Start;
var end = visibleBytesSpan.Start + bytesPerLine;
int? visStart = null;
int? visEnd = null;
int cellPos = 0;
for (ulong i = 0; i < cellCount; i++) {
if (i != 0)
stringBuilder.Append(' ');
int groupIndex = (cellPos / groupSizeInBytes) & 1;
HexBufferSpan bufferSpan;
int cellStart = CurrentTextIndex;
int spaces;
if (visibleBytesSpan.Contains(pos)) {
if (visStart == null)
visStart = CurrentTextIndex;
long valueIndex = (long)(pos - visibleBytesSpan.Start).ToUInt64();
spaces = valueFormatter.FormatValue(stringBuilder, hexBytes, valueIndex, flags);
var endPos = HexPosition.Min(endPosition, pos + (ulong)valueFormatter.ByteCount);
bufferSpan = new HexBufferSpan(new HexBufferPoint(buffer, pos), new HexBufferPoint(buffer, endPos));
}
else {
if (visStart != null && visEnd == null)
visEnd = CurrentTextIndex;
stringBuilder.Append(' ', valueFormatter.FormattedLength);
spaces = valueFormatter.FormattedLength;
bufferSpan = default(HexBufferSpan);
}
if (cellStart + valueFormatter.FormattedLength != CurrentTextIndex)
throw new InvalidOperationException();
var textSpan = VST.Span.FromBounds(cellStart + spaces, CurrentTextIndex);
var cellSpan = VST.Span.FromBounds(cellStart, CurrentTextIndex);
VST.Span separatorSpan;
if (i + 1 < cellCount)
separatorSpan = new VST.Span(CurrentTextIndex, 1);
else
separatorSpan = new VST.Span(CurrentTextIndex, 0);
var cellFullSpan = VST.Span.FromBounds(cellStart, separatorSpan.End);
cellList.Add(new HexCell((int)i, groupIndex, bufferSpan, textSpan, cellSpan, separatorSpan, cellFullSpan));
pos += (ulong)valueFormatter.ByteCount;
cellPos += valueFormatter.ByteCount;
}
if (pos != end)
throw new InvalidOperationException();
if (visStart != null && visEnd == null)
visEnd = CurrentTextIndex;
visibleSpan = visStart == null ? default(VST.Span) : VST.Span.FromBounds(visStart.Value, visEnd.Value);
fullSpan = VST.Span.FromBounds(fullStart, CurrentTextIndex);
if (ValuesSpan != fullSpan)
throw new InvalidOperationException();
return cellList.ToArray();
}