本文整理汇总了C#中SubRecord.Max方法的典型用法代码示例。如果您正苦于以下问题:C# SubRecord.Max方法的具体用法?C# SubRecord.Max怎么用?C# SubRecord.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubRecord
的用法示例。
在下文中一共展示了SubRecord.Max方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSubRecord
private void ProcessSubRecord(Subrecord sr, SubRecord[] srs)
{
long minSize = srs.Min(a => a.Size);
long maxSize = srs.Max(a => a.Size);
if (maxSize == 0)
{
// likely a group start
sr.size = -1;
return;
}
int szCount = 0;
foreach (var ss in srs)
{
if (ss.Size == 0)
{
continue;
}
var data = ss.GetReadonlyData();
if (IsLikelyString(new ArraySegment<byte>(data, 0, (int) ss.Size)))
{
if (++szCount > 10)
{
var elem = CreateType(null, "string");
sr.Items.Add(elem);
break;
}
}
else
{
break;
}
}
if (sr.Elements.Any())
{
return; // found string
}
if (minSize == maxSize && maxSize < 256)
{
sr.size = (int) maxSize;
int index = 0;
// Walk through each element guessing the data type
for (int offset = 0, elemSize = 4; offset < maxSize; offset += elemSize)
{
int numZero = 0;
int numFloat = 0;
int num2Short = 0;
int isFormID = 0;
int numTotal = 0;
int isLString = 0;
string reftype = null;
if (maxSize - offset < 4)
{
if (maxSize >= 2)
{
var elem = CreateType(index++, "short");
elem.size = 2;
sr.Items.Add(elem);
elemSize = 2;
continue;
}
else
{
var elem = CreateType(index++, "byte");
elem.size = 1;
sr.Items.Add(elem);
elemSize = 1;
continue;
}
}
foreach (var ss in srs)
{
// .Random(srs.Length < 10 ? 0 : srs.Length / 10)
++numTotal;
var data = ss.GetReadonlyData();
uint ui4 = TypeConverter.h2i(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
if (ui4 == 0)
{
++numZero;
continue;
}
ushort lhs = TypeConverter.h2s(data[offset], data[offset + 1]);
ushort uhs = TypeConverter.h2s(data[offset + 2], data[offset + 3]);
float flt = TypeConverter.h2f(data[offset], data[offset + 1], data[offset + 2], data[offset + 3]);
if (IsLikelyFloat(flt))
{
++numFloat;
}
if (lhs > 0 && lhs < 255 && uhs > 0 && uhs < 255)
{
++num2Short;
}
//.........这里部分代码省略.........