コード例 #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,
                           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;
コード例 #2
0
 public virtual void CopyInFromBinary(
     IVirtualMachineAdapter item,
     MutagenFrame frame,
     RecordTypeConverter?recordTypeConverter = null)
 {
     frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseSubrecord(
                                              frame.Reader,
                                              recordTypeConverter.ConvertToCustom(RecordTypes.VMAD)));
     PluginUtilityTranslation.SubrecordParse(
         record: item,
         frame: frame,
         recordTypeConverter: recordTypeConverter,
         fillStructs: VirtualMachineAdapterBinaryCreateTranslation.FillBinaryStructs);
 }
コード例 #3
0
 public virtual void CopyInFromBinary(
     IVirtualMachineAdapter item,
     MutagenFrame frame,
     TypedParseParams?translationParams = null)
 {
     frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseSubrecord(
                                              frame.Reader,
                                              translationParams.ConvertToCustom(RecordTypes.VMAD),
                                              translationParams?.LengthOverride));
     PluginUtilityTranslation.SubrecordParse(
         record: item,
         frame: frame,
         translationParams: translationParams,
         fillStructs: VirtualMachineAdapterBinaryCreateTranslation.FillBinaryStructs);
 }
コード例 #4
0
ファイル: UtilityTranslation.cs プロジェクト: halgari/Mutagen
        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);
            }
            MutagenFrame targetFrame = frame;

            if (record.IsCompressed)
            {
                targetFrame = frame.Decompress();
            }
            while (!targetFrame.Complete)
            {
                var subMeta  = targetFrame.GetSubrecord();
                var finalPos = targetFrame.Position + subMeta.TotalLength;
                var parsed   = fillTyped(
                    record: record,
                    frame: targetFrame,
                    nextRecordType: subMeta.RecordType,
                    contentLength: subMeta.ContentLength,
                    recordTypeConverter: recordTypeConverter);
                if (parsed.Failed)
                {
                    break;
                }
                if (targetFrame.Position < finalPos)
                {
                    targetFrame.Position = finalPos;
                }
            }
            frame.SetToFinalPosition();
            return(record);
        }
コード例 #5
0
        public static M MajorRecordParse <M>(
            M record,
            MutagenFrame frame,
            TypedParseParams?translationParams,
            RecordStructFill <M> fillStructs,
            MajorRecordFill <M> fillTyped)
            where M : IMajorRecordGetter
        {
            frame = frame.SpawnWithFinalPosition(HeaderTranslation.ParseRecord(frame.Reader));
            fillStructs(
                record: record,
                frame: frame);
            try
            {
                MutagenFrame targetFrame = frame;
                if (record.IsCompressed)
                {
                    targetFrame = frame.Decompress();
                }

                Dictionary <RecordType, int>?recordParseCount = null;
                frame.MetaData.FormVersion = record.FormVersion;
                var lastParsed = new PreviousParse();
                while (!targetFrame.Complete)
                {
                    var         subMeta  = targetFrame.GetSubrecord();
                    var         finalPos = targetFrame.Position + subMeta.TotalLength;
                    ParseResult parsed;
                    try
                    {
                        parsed = fillTyped(
                            record: record,
                            frame: targetFrame,
                            lastParsed: lastParsed,
                            recordParseCount: recordParseCount,
                            nextRecordType: subMeta.RecordType,
                            contentLength: lastParsed.LengthOverride ?? subMeta.ContentLength,
                            translationParams: translationParams);
                    }
                    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] =