Beispiel #1
0
 public static M MajorRecordParse <M>(
     M record,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter,
     RecordStructFill <M> fillStructs,
     RecordTypeFill <M> fillTyped)
     where M : IMajorRecordCommonGetter
 {
     frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseRecord(frame.Reader));
     fillStructs(
         record: record,
         frame: frame);
     if (fillTyped == null)
     {
         return(record);
     }
     try
     {
         MutagenFrame targetFrame = frame;
         if (record.IsCompressed)
         {
             targetFrame = frame.Decompress();
         }
         Dictionary <RecordType, int>?recordParseCount = null;
         frame.MetaData.FormVersion = record.FormVersion;
         while (!targetFrame.Complete)
         {
             var         subMeta  = targetFrame.GetSubrecord();
             var         finalPos = targetFrame.Position + subMeta.TotalLength;
             ParseResult parsed;
             try
             {
                 parsed = fillTyped(
                     record: record,
                     frame: targetFrame,
                     recordParseCount: recordParseCount,
                     nextRecordType: subMeta.RecordType,
                     contentLength: subMeta.ContentLength,
                     recordTypeConverter: recordTypeConverter);
             }
             catch (Exception ex)
             {
                 throw new SubrecordException(
                           subMeta.RecordType,
                           record.FormKey,
                           majorRecordType: record.Registration.ClassType,
                           modKey: frame.Reader.MetaData.ModKey,
                           edid: record.EditorID,
                           innerException: ex);
             }
             if (!parsed.KeepParsing)
             {
                 break;
             }
             if (parsed.DuplicateParseMarker != null)
             {
                 if (recordParseCount == null)
                 {
                     recordParseCount = new Dictionary <RecordType, int>();
                 }
                 recordParseCount[parsed.DuplicateParseMarker !.Value] = recordParseCount.GetOrAdd(parsed.DuplicateParseMarker !.Value) + 1;