/// <summary>
        /// Creates a module reference from a module reference metadata row.
        /// </summary>
        /// <param name="parentModule">The module that contains the module reference.</param>
        /// <param name="token">The token to initialize the module reference for.</param>
        /// <param name="row">The metadata table row to base the module reference. on.</param>
        public SerializedModuleReference(SerializedModuleDefinition parentModule, MetadataToken token, ModuleReferenceRow row)
            : base(token)
        {
            _parentModule = parentModule ?? throw new ArgumentNullException(nameof(parentModule));
            _row          = row;

            ((IOwnedCollectionElement <ModuleDefinition>) this).Owner = parentModule;
        }
Beispiel #2
0
        /// <summary>
        /// Adds a single module reference to the buffer.
        /// </summary>
        /// <param name="reference">The reference to add.</param>
        /// <returns>The new metadata token assigned to the module reference.</returns>
        public MetadataToken GetModuleReferenceToken(ModuleReference reference)
        {
            AssertIsImported(reference);

            var table = Metadata.TablesStream.GetTable <ModuleReferenceRow>(TableIndex.ModuleRef);

            var row   = new ModuleReferenceRow(Metadata.StringsStream.GetStringIndex(reference.Name));
            var token = table.Add(row);

            AddCustomAttributes(token, reference);
            return(token);
        }