GetRecordInfo() public static method

public static GetRecordInfo ( Type type ) : RecordInfo
type System.Type
return RecordInfo
Ejemplo n.º 1
0
        internal void WriteRecord(GenericFormRecord record, uint formId)
        {
            if (header == null)
            {
                throw new InvalidOperationException("Header not yet written");
            }

            FormKind formKind = (FormKind)InfoProvider.GetRecordInfo(record.GetType()).Signature;

            if (formKind != currentGroupFormKind)
            {
                // End existing group if one has begun
                if (currentGroupFormKind != FormKind.Any)
                {
                    EndSegment();
                }

                currentGroupFormKind = formKind;
                BeginGroupSegment(currentGroupFormKind);
                numRecords++;
            }

            // Convert global context Form ID to local relative Form ID
            uint localFormId = ReferenceMapper.ContexToLocal(formId);

            DoWriteRecord(record, localFormId);
            numRecords++;
        }
Ejemplo n.º 2
0
        private void DoWriteRecord(Record record, uint formId)
        {
            var recinfo = InfoProvider.GetRecordInfo(record.GetType());

            BeginRecordSegment(recinfo.Signature, record.RawFlags, record.Version, formId);

            record.WriteRecord(this);

            EndSegment();
        }
Ejemplo n.º 3
0
        internal void ReadRecord(RecordReader reader, bool lazyLoading)
        {
            var compinfo = InfoProvider.GetCompoundInfo(GetType());
            var recinfo  = InfoProvider.GetRecordInfo(GetType());

            BeforeRead(reader);

            reader.BeginReadFields(0);

            HashSet <string> remainingPropertiesToLoad = lazyLoading ? new HashSet <string>(compinfo.Members.Values.Where(m => m.IsLazy).SelectMany(m => m.FieldNames)) : null;

            foreach (string propertyName in reader.FindFields())
            {
                MemberInfo meminf = compinfo.FindMember(propertyName);
                if (meminf != null)
                {
                    reader.ReadField(this, propertyName, meminf, 0);

                    if (remainingPropertiesToLoad != null)
                    {
                        if (!meminf.IsListType && !meminf.IsDynamic)
                        {
                            remainingPropertiesToLoad.Remove(propertyName);
                        }

                        if (!remainingPropertiesToLoad.Any())
                        {
                            // Loaded all properties that were supposed to
                            reader.CancelFindFields();
                            break;
                        }
                    }
                }
                else if (lazyLoading || recinfo.IsDummyRecord)
                {
                    // Prevent segment errors when not all properties were expected to be consumed
                    reader.SeekEndOfSegment();
                }
                else
                {
                    Log.Warning("Unexpected record property: {0}", propertyName);
                }
            }

            reader.EndReadFields(0);

            //// Make sure list properties that were supposed to be loaded are not null
            //foreach (MemberInfo meminfo in members.Where(m => m.Value.IsListType && (fieldsToLoad == null || fieldsToLoad.Contains(m.Key))).Select(m => m.Value))
            //{
            //    meminfo.EnsureListCreated(this);
            //}

            AfterRead(reader);
        }
Ejemplo n.º 4
0
        public GenericFormRecord CopyRecord()
        {
            var recinfo = InfoProvider.GetRecordInfo(GetType());
            var other   = recinfo.CreateInstance();

            BeforeCopy(other);

            // Copy raw flags and version
            other.RawFlags = RawFlags;
            other.Version  = Version;

            var compinfo = InfoProvider.GetCompoundInfo(GetType());

            compinfo.Copy(this, other);

            AfterCopy(other);

            return(other);
        }
Ejemplo n.º 5
0
        private void DoReadRecord(GenericFormRecord record, bool lazyLoading)
        {
            RecordInfo recinf = InfoProvider.GetRecordInfo(record.GetType());

            if (record.GetType() != typeof(DummyRecord) && recinf.Signature != CurrentSegment.Signature)
            {
                throw new InvalidOperationException("Record signature mismatch.");
            }

            if (record.IsRecordCompressed)
            {
                // TODO: Intermediate MomeryStream may not be needed here
                long   decompressedSize = ReadUInt32();
                byte[] compressedData   = ReadBytesToEnd();
                Stream compressedStream = new MemoryStream(compressedData);
                Stream deflateStream    = new CustomDeflateStream(compressedStream, decompressedSize);
                using (RecordReader deflateReader = context.CreateReader(deflateStream))
                {
                    deflateReader.CurrentState = States.Reading;

                    // Copy flags etc to the deflate reader
                    deflateReader.PluginFlags     = PluginFlags;
                    deflateReader.ReferenceMapper = ReferenceMapper;
                    deflateReader.StringLocator   = StringLocator;

                    // Read record form the deflate reader
                    deflateReader.CurrentRecord = record;
                    record.ReadRecord(deflateReader, lazyLoading);
                    deflateReader.CurrentRecord = null;
                }
            }
            else
            {
                // Read record form the current reader
                CurrentRecord = record;
                record.ReadRecord(this, lazyLoading);
                CurrentRecord = null;
            }
        }