public IEnumerable<KeyValuePair<uint, Record>> EnumerateRecords(string type)
{
var list = new Dictionary<uint, string>();
// search each master reference. Override any
for (int i = 0; i < this.Masters.Length - 1; i++)
{
if (this.Masters[i] == null)
{
continue; // missing master
}
uint match = this.Fixups[i];
match <<= 24;
uint mask = (uint)i << 24;
// This enumerate misses any records that are children of masters
foreach (var r in this.Masters[i].Enumerate(
r =>
{
if (r is Record)
{
if ((type == null || r.Name == type) && (((Record)r).FormID & 0xFF000000) == match)
{
return true;
}
}
else if (r is GroupRecord)
{
var gr = (GroupRecord)r;
if (gr.groupType != 0 || gr.ContentsType == type)
{
return true;
}
}
else if (r is Plugin)
{
return true;
}
return false;
}))
{
if (r is Record)
{
var r2 = r as Record;
yield return new KeyValuePair<uint, Record>((r2.FormID & 0xffffff) | mask, r2);
}
}
}
// finally add records of self in to the list
foreach (var r in this.Enumerate(
r =>
{
if (r is Record)
{
if (type == null || r.Name == type)
{
return true;
}
}
else if (r is GroupRecord)
{
var gr = (GroupRecord)r;
if (gr.groupType != 0 || type == null || gr.ContentsType == type)
{
return true;
}
}
else if (r is Plugin)
{
return true;
}
return false;
}))
{
if (r is Record)
{
var r2 = r as Record;
yield return new KeyValuePair<uint, Record>(r2.FormID, r2);
}
}
}