本文整理汇总了C#中SubRecord.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# SubRecord.Sum方法的具体用法?C# SubRecord.Sum怎么用?C# SubRecord.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubRecord
的用法示例。
在下文中一共展示了SubRecord.Sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSubRecord
//.........这里部分代码省略.........
float lstrPct = (isLString + numZero)/(float) numTotal;
if (numFloat > 0 && floatPct > 0.5f)
{
var elem = CreateType(index++, "float");
elem.size = 4;
sr.Items.Add(elem);
}
else if (num2Short > 0 && shortPct > 0.5f)
{
var elem = CreateType(index++, "short");
elem.size = 2;
sr.Items.Add(elem);
sr.Items.Add(elem);
UpdateSize(sr);
}
else if (isFormID > 0 && formPct > 0.5f)
{
var elem = CreateType(index++, "formid");
elem.reftype = reftype;
elem.size = 4;
sr.Items.Add(elem);
}
else if (isLString > 0 && lstrPct > 0.5f)
{
var elem = CreateType(index++, "lstring");
elem.size = 4;
sr.Items.Add(elem);
}
else
{
var elem = CreateType(index++, "int");
elem.size = 4;
sr.Items.Add(elem);
}
}
}
}
else
{
// guess dynamically sized object... default to blob
if (!sr.Elements.Any())
{
long modSum = srs.Sum(a => a.Size%4); // useful if we suspect this is an array of integers
if (modSum == 0)
{
int count = 0;
string reftype = null;
foreach (var ss in srs)
{
var data = ss.GetReadonlyData();
int offset = 0;
uint ui4 = GetUInt32(data, offset);
if (ui4 < 100)
{
continue;
}
var r = FormLookup(ui4);
if (r != null)
{
if (string.IsNullOrEmpty(reftype))
{
reftype = r.Name;
}
else if (reftype == r.Name)
{
if (++count > 10)
{
break;
}
}
}
else
{
break;
}
}
if (count > 0)
{
var elem = CreateType("ID", "formid");
elem.reftype = reftype;
elem.size = 4;
elem.repeat = 1;
elem.optional = 1;
sr.Items.Add(elem);
}
}
}
// check if it is a string else make it a blob
sr.size = 0;
if (!sr.Elements.Any())
{
sr.Items.Add(CreateBlob());
}
}
}