示例#1
0
        internal static object ProcessSubRecord(SubRecordOperationType operation, ISubRecordOperationContext context)
        {
            var key = new SubRecordProcessKey(context.RecordName, context.SubRecordName, operation);

            if (!SubRecordProcessingDefinitions.ContainsKey(key))
            {
                throw new ArgumentException($"Unrecognized sub-record operation: {key}");
            }

            if (operation == SubRecordOperationType.Read)
            {
                var readContext = (SubRecordReadContext)context;
                if (readContext.buf.Length < readContext.header.Size)
                {
                    var buf0 = new byte[readContext.header.Size + REALLOCATION_STEP_SIZE];
                    Array.Copy(readContext.buf, buf0, readContext.buf.Length);
                    readContext.buf = buf0;
                }

                readContext.stream.Read(readContext.buf, 0, readContext.header.Size);
            }


            return(SubRecordProcessingDefinitions[key].Invoke(null, new object[] { context }));
        }
示例#2
0
 internal SubRecordProcessKey(string recordName, string subRecordName, SubRecordOperationType type)
 {
     this.recordName    = recordName;
     this.subRecordName = subRecordName;
     this.type          = type;
 }
示例#3
0
 internal HandlesOperation(SubRecordOperationType operation)
 {
     SubRecordOperation = operation;
 }