예제 #1
0
            private void LoadFields()
            {
                if (!_metadataStream.Tables.ContainsKey(MetadataTables.Field))
                {
                    return;
                }

                MetadataRow[] table           = _metadataStream.Tables[MetadataTables.Field];
                int           endOfFieldIndex = table.Length + 1;

                if (_nextRowIndex != -1)
                {
                    endOfFieldIndex = ((TypeDefMetadataTableRow)_metadataStream.Tables[MetadataTables.TypeDef][_nextRowIndex]).FieldList;
                }

                // Now load all the fields between our index and the endOfFieldIndex
                for (int i = _fromRow.FieldList; i < endOfFieldIndex; i++)
                {
                    FieldMetadataTableRow fieldDefRow = table[i - 1] as FieldMetadataTableRow;

                    FieldDef field = new FieldDef(
                        _references.Assembly.StringStream.GetString(fieldDefRow.Name.Value),
                        _references.Assembly,
                        _builtType,
                        fieldDefRow.Flags,
                        fieldDefRow.Signiture
                        );

                    _map.Add(MetadataTables.Field, fieldDefRow, field);
                    _builtType.Fields.Add(field);
                }
            }
예제 #2
0
 public FieldEntry(MetadataDirectory directory, FieldMetadataTableRow row)
 {
     this.FileOffset = string.Format("0x{0:x}", row.FileOffset);
     this.Name       = ((StringStream)directory.Streams[Streams.StringStream]).GetString(row.Name.Value);
     this.Flags      = row.Flags.ToString();
     this.Signiture  = string.Format("0x{0:x}", row.Signiture.Value);
 }
        public void Field_WhenCreated_OffsetIsMovedOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[20];
            Offset offset   = 0;

            FieldMetadataTableRow row = new FieldMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        public void Field_WhenCreated_FieldsAreReadCorrectly()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x06, 0x00,
                0x01, 0x00,
                0x01, 0x00
            };

            FieldMetadataTableRow row = new FieldMetadataTableRow(contents, 0, indexDetails);

            Assert.AreEqual(FieldAttributes.Public, row.Flags);
            Assert.AreEqual(1, row.Name.Value);
            Assert.AreEqual(1, row.Signiture.Value);
            Assert.AreEqual(Signatures.Field, row.Signiture.SignitureType);
        }