Esempio n. 1
0
        public Compound()
        {
            // Initialize fields that should not be null
            var members = InfoProvider.GetCompoundInfo(GetType()).Members;

            foreach (var meminfo in members.Values.Distinct().Where(m => m.Initialize))
            {
                if (meminfo.IsListType)
                {
                    // Instantiate list field
                    meminfo.EnsureListCreated(this);
                }
                else if (!meminfo.IsPrimitiveType)
                {
                    // Instantiate complex fields
                    var fieldinfo = InfoProvider.GetFieldInfo(meminfo.FieldType);
                    meminfo.SetValue(this, fieldinfo.CreateInstance());
                }
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
        public override IEnumerable <uint> GetReferencedFormIds()
        {
            var compinfo = InfoProvider.GetCompoundInfo(GetType());

            return(compinfo.GetReferencedFormIds(this));
        }
Esempio n. 4
0
        public override bool Equals(Field other)
        {
            var compinfo = InfoProvider.GetCompoundInfo(GetType());

            return(compinfo.Equate(this, other));
        }