Freigeben über


IMetaDataEmit Interface

Provides methods to create, modify, and save metadata about the assembly in the currently defined scope. The metadata can be stored in memory or saved to disk.

interface IMetaDataEmit : IUnknown {
        
    HRESULT ApplyEditAndContinue ( 
        [in]  IUnknown    *pImport
    );
        
    HRESULT DefineCustomAttribute ( 
        [in]  mdToken     tkObj, 
        [in]  mdToken     tkType, 
        [in]  void const  *pCustomAttribute, 
        [in]  ULONG       cbCustomAttribute, 
        [out] mdCustomAttribute *pcv 
    );
        
    HRESULT DefineEvent (    
        [in]  mdTypeDef   td, 
                [in]  LPCWSTR     szEvent, 
        [in]  DWORD       dwEventFlags, 
                [in]  mdToken     tkEventType, 
        [in]  mdMethodDef mdAddOn, 
        [in]  mdMethodDef mdRemoveOn, 
        [in]  mdMethodDef mdFire, 
        [in]  mdMethodDef rmdOtherMethods[], 
        [out] mdEvent     *pmdEvent 
    );
        
    HRESULT DefineField ( 
        [in]  mdTypeDef   td, 
                [in]  LPCWSTR     szName, 
        [in]  DWORD       dwFieldFlags, 
                [in]  PCCOR_SIGNATURE pvSigBlob, 
        [in]  ULONG       cbSigBlob, 
        [in]  DWORD       dwCPlusTypeFlag, 
        [in]  void const  *pValue, 
        [in]  ULONG       cchValue, 
        [out] mdFieldDef  *pmd 
    );
        
    HRESULT DefineImportMember ( 
        [in]  IMetaDataAssemblyImport *pAssemImport, 
        [in]  const void  *pbHashValue, 
        [in]  ULONG       cbHashValue,
        [in]  IMetaDataImport *pImport, 
        [in]  mdToken     mbMember, 
        [in]  IMetaDataAssemblyEmit *pAssemEmit, 
        [in]  mdToken     tkParent, 
        [out] mdMemberRef *pmr 
    );
        
    HRESULT DefineImportType ( 
        [in]  IMetaDataAssemblyImport *pAssemImport, 
        [in]  const void  *pbHashValue, 
        [in]  ULONG       cbHashValue,  
        [in]  IMetaDataImport *pImport, 
        [in]  mdTypeDef   tdImport, 
        [in]  IMetaDataAssemblyEmit *pAssemEmit, 
        [out] mdTypeRef   *ptr
    );
        
    HRESULT DefineMemberRef ( 
        [in]  mdToken     tkImport, 
        [in]  LPCWSTR     szName, 
        [in]  PCCOR_SIGNATURE pvSigBlob, 
        [in]  ULONG       cbSigBlob, 
        [out] mdMemberRef *pmr 
    );
        
    HRESULT DefineMethod (    
        [in]  mdTypeDef   td, 
        [in]  LPCWSTR     szName, 
        [in]  DWORD       dwMethodFlags, 
        [in]  PCCOR_SIGNATURE pvSigBlob, 
        [in]  ULONG       cbSigBlob, 
        [in]  ULONG       ulCodeRVA, 
        [in]  DWORD       dwImplFlags, 
        [out] mdMethodDef *pmd
    );
        
    HRESULT DefineMethodImpl ( 
        [in]  mdTypeDef   td, 
        [in]  mdToken     tkBody, 
        [in]  mdToken     tkDecl
    );
        
    HRESULT DefineModuleRef (   
        [in]  LPCWSTR     szName, 
        [out] mdModuleRef *pmur 
    );
        
    HRESULT DefineNestedType ( 
        [in]  LPCWSTR     szTypeDef,
        [in]  DWORD       dwTypeDefFlags, 
        [in]  mdToken     tkExtends, 
        [in]  mdToken     rtkImplements[], 
        [in]  mdTypeDef   tdEncloser, 
        [out] mdTypeDef   *ptd
    );
        
    HRESULT DefineParam (
        [in]  mdMethodDef md, 
        [in]  ULONG       ulParamSeq, 
        [in]  LPCWSTR     szName, 
                [in]  DWORD       dwParamFlags, 
        [in]  DWORD       dwCPlusTypeFlag, 
                [in]  void const  *pValue,
        [in]  ULONG       cchValue, 
        [out] mdParamDef  *ppd 
    );
        
    HRESULT DefinePermissionSet (    
        [in]  mdToken     tk, 
        [in]  DWORD       dwAction, 
        [in]  void const  *pvPermission, 
        [in]  ULONG       cbPermission, 
        [out] mdPermission *ppm 
    );
        
    HRESULT DefinePinvokeMap ( 
        [in]  mdToken     tk, 
        [in]  DWORD       dwMappingFlags, 
        [in]  LPCWSTR     szImportName, 
        [in]  mdModuleRef mrImportDLL 
    );
        
    HRESULT DefineProperty ( 
        [in]  mdTypeDef   td, 
        [in]  LPCWSTR     szProperty, 
                [in]  DWORD       dwPropFlags, 
        [in]  PCCOR_SIGNATURE pvSig, 
        [in]  ULONG       cbSig, 
        [in]  DWORD       dwCPlusTypeFlag, 
                [in]  void const  *pValue, 
        [in]  ULONG       cchValue, 
        [in]  mdMethodDef mdSetter, 
        [in]  mdMethodDef mdGetter, 
        [in]  mdMethodDef rmdOtherMethods[], 
        [out] mdProperty  *pmdProp 
    );
        
    HRESULT DefineSecurityAttributeSet ( 
        [in]  mdToken     tkObj, 
        [in]  COR_SECATTR rSecAttrs[], 
        [in]  ULONG       cSecAttrs, 
        [out] ULONG       *pulErrorAttr 
    );
        
    HRESULT DefineTypeDef ( 
                [in]  LPCWSTR     szTypeDef, 
        [in]  DWORD       dwTypeDefFlags, 
                [in]  mdToken     tkExtends, 
        [in]  mdToken     rtkImplements[], 
        [out] mdTypeDef   *ptd
    );
        
    HRESULT DefineTypeRefByName ( 
        [in]  mdToken     tkResolutionScope, 
        [in]  LPCWSTR     szName, 
        [out] mdTypeRef   *ptr 
    );
        
    HRESULT DefineUserString ( 
        [in]  LPCWSTR szString, 
        [in]  ULONG       cchString, 
        [out] mdString    *pstk 
    );
        
    HRESULT DeleteClassLayout (
        [in]  mdTypeDef   td
    );
        
    HRESULT DeleteFieldMarshal (
        [in]  mdToken     tk
    );
        
    HRESULT DeletePinvokeMap ( 
        [in]  mdToken     tk 
    );
        
    HRESULT DeleteToken ( 
        [in]  mdToken     tkObj 
    );
        
    HRESULT GetSaveSize (    
        [in]  CorSaveSize fSave,
        [out] DWORD       *pdwSaveSize
    );
        
    HRESULT GetTokenFromSig (   
        [in]  PCCOR_SIGNATURE pvSig, 
        [in]  ULONG       cbSig, 
        [out] mdSignature *pmsig 
    );
        
    HRESULT GetTokenFromTypeSpec ( 
        [in]  PCCOR_SIGNATURE pvSig, 
        [in]  ULONG       cbSig, 
        [out] mdTypeSpec *ptypespec 
    ); 
        
    HRESULT Merge ( 
        [in]  IMetaDataImport *pImport, 
        [in]  IMapToken   *pHostMapToken, 
        [in]  IUnknown    *pHandler 
    );
        
    HRESULT MergeEnd ();
        
    HRESULT Save ( 
        [in]  LPCWSTR     szFile, 
        [in]  DWORD       dwSaveFlags
    );
        
    HRESULT SaveToMemory (   
        [in]  void        *pbData, 
        [in]  ULONG       cbData 
    );
        
    HRESULT SaveToStream (   
        [in]  IStream     *pIStream,
        [in]  DWORD       dwSaveFlags
    );
        
    HRESULT SetClassLayout (   
        [in]  mdTypeDef   td, 
        [in]  DWORD       dwPackSize, 
        [in]  COR_FIELD_OFFSET rFieldOffsets[], 
        [in]  ULONG       ulClassSize 
    );
        
    HRESULT SetCustomAttributeValue ( 
        [in]  mdCustomAttribute pcv, 
        [in]  void const  *pCustomAttribute,  
        [in]  ULONG       cbCustomAttribute 
    );
        
    HRESULT SetEventProps (  
        [in]  mdEvent     ev, 
        [in]  DWORD       dwEventFlags, 
        [in]  mdToken     tkEventType, 
        [in]  mdMethodDef mdAddOn, 
        [in]  mdMethodDef mdRemoveOn, 
        [in]  mdMethodDef mdFire, 
        [in]  mdMethodDef rmdOtherMethods[] 
    );
        
    HRESULT SetFieldMarshal (    
        [in]  mdToken     tk, 
        [in]  PCCOR_SIGNATURE pvNativeType, 
        [in]  ULONG       cbNativeType 
    );
        
    HRESULT SetFieldProps (  
                [in]  mdFieldDef  fd, 
        [in]  DWORD       dwFieldFlags, 
        [in]  DWORD       dwCPlusTypeFlag, 
                [in]  void const  *pValue, 
        [in]  ULONG       cchValue 
    );
        
    HRESULT SetFieldRVA ( 
        [in]  mdFieldDef  fd, 
        [in]  ULONG       ulRVA 
    );
        
    HRESULT SetHandler ( 
        [in]  IUnknown    *pUnk
    );
        
    HRESULT SetMethodProps ( 
        [in]  mdMethodDef md, 
        [in]  DWORD       dwMethodFlags,
        [in]  ULONG       ulCodeRVA, 
        [in]  DWORD       dwImplFlags 
    );
        
    HRESULT SetMethodImplFlags ( 
                [in]  mdMethodDef md, 
        [in]  DWORD       dwImplFlags 
        );
        
    HRESULT SetModuleProps ( 
        [in]  LPCWSTR     szName
    ); 
        
    HRESULT SetParamProps ( 
        [in]  mdParamDef  pd, 
        [in]  LPCWSTR     szName, 
        [in]  DWORD       dwParamFlags, 
        [in]  DWORD       dwCPlusTypeFlag, 
        [in]  void const  *pValue, 
        [in]  ULONG       cchValue 
    );
        
    HRESULT SetParent ( 
        [in]  mdMemberRef mr, 
        [in]  mdToken     tk 
    );
        
    HRESULT SetPermissionSetProps ( 
        [in]  mdToken     tk, 
        [in]  DWORD       dwAction, 
        [in]  void const  *pvPermission, 
        [in]  ULONG       cbPermission, 
        [out] mdPermission *ppm 
    );
        
    HRESULT SetPinvokeMap ( 
        [in]  mdToken     tk, 
        [in]  DWORD       dwMappingFlags,
        [in]  LPCWSTR     szImportName, 
        [in]  mdModuleRef mrImportDLL 
    );
        
    HRESULT SetPropertyProps ( 
        [in]  mdProperty  pr, 
                [in]  DWORD       dwPropFlags, 
        [in]  DWORD       dwCPlusTypeFlag, 
                [in]  void const  *pValue, 
        [in]  ULONG       cchValue, 
        [in]  mdMethodDef mdSetter, 
        [in]  mdMethodDef mdGetter, 
        [in]  mdMethodDef rmdOtherMethods[] 
    );
        
    HRESULT SetRVA ( 
        [in]  mdMethodDef md, 
        [in]  ULONG       ulRVA 
    );
        
    HRESULT SetTypeDefProps (
        [in]  mdTypeDef   td, 
                [in]  DWORD       dwTypeDefFlags, 
        [in]  mdToken     tkExtends, 
                [in]  mdToken     rtkImplements[] 
    );
        
    HRESULT TranslateSigWithScope ( 
        [in]  IMetaDataAssemblyImport *pAssemImport, 
        [in]  const void  *pbHashValue, 
        [in]  ULONG       cbHashValue, 
        [in]  IMetaDataImport *import, 
        [in]  PCCOR_SIGNATURE pbSigBlob, 
        [in]  ULONG       cbSigBlob,
        [in]  IMetaDataAssemblyEmit *pAssemEmit, 
        [in]  IMetaDataEmit *emit, 
        [out] PCOR_SIGNATURE pvTranslatedSig, 
        [in]  ULONG       cbTranslatedSigMax, 
        [out] ULONG       *pcbTranslatedSig 
    );
        
};

Methods

Method Description

IMetaDataEmit::ApplyEditAndContinue Method

Updates the current assembly scope with the changes made in the specified pImport.

IMetaDataEmit::DefineCustomAttribute Method

Creates a definition for a custom attribute with the specified metadata signature, to be attached to the specified object, and gets a token to that custom attribute definition.

IMetaDataEmit::DefineEvent Method

Creates a definition for an event with the specified metadata signature, and gets a token to that event definition.

IMetaDataEmit::DefineField Method

Creates a definition for a field with the specified metadata signature, and gets a token to that field definition.

IMetaDataEmit::DefineImportMember Method

Creates a definition for a member of a type that is defined in a module outside the current scope, and gets a token for that reference definition.

IMetaDataEmit::DefineImportType Method

Creates a definition for a reference to a type that is defined in a module outside the current scope, and gets a token to that reference definition.

IMetaDataEmit::DefineMemberRef Method

Creates a definition for a reference to a member of a module outside the current scope, and gets a token to that reference definition.

IMetaDataEmit::DefineMethod Method

Creates a definition for a method with the specified signature, and returns a token to that method definition.

IMetaDataEmit::DefineMethodImpl Method

Creates a definition for implementation of a method inherited from an interface, and returns a token to that method-implementation definition.

IMetaDataEmit::DefineModuleRef Method

Creates the metadata signature for a module with the specified name.

IMetaDataEmit::DefineNestedType Method

Creates the metadata signature of a type definition and returns an mdTypeDef token for that type, additionally specifying that the defined type is a member of the type referenced by tdEncloser.

IMetaDataEmit::DefineParam Method

Creates a parameter definition with the specified signature for the method referenced by the specified token, and gets a token for that parameter definition.

IMetaDataEmit::DefinePermissionSet Method

Creates a definition for a permission set with the specified metadata signature, and gets a token to that permission set definition.

IMetaDataEmit::DefinePinvokeMap Method

Sets features of the PInvoke signature of the method referenced by the specified token.

IMetaDataEmit::DefineProperty Method

Creates a property definition for the specified type, with the specified get and set method accessors, and gets a token to that property definition.

IMetaDataEmit::DefineSecurityAttributeSet Method

Creates a set of security permissions to attach to the object referenced by the specified token.

IMetaDataEmit::DefineTypeDef Method

Creates a type definition for a common language runtime type, and gets a metadata token to that type definition.

IMetaDataEmit::DefineTypeRefByName Method

Gets a metadata token for a type that is defined in another module outside the current scope.

IMetaDataEmit::DefineUserString Method

Gets a metadata token for the specified literal string.

IMetaDataEmit::DeleteClassLayout Method

Destroys the class layout metadata signature for the type referenced by the specified token.

IMetaDataEmit::DeleteFieldMarshal Method

Destroys the PInvoke marshaling metadata signature for the object referenced by the specified token.

IMetaDataEmit::DeletePinvokeMap Method

Destroys the PInvoke mapping metadata for the object referenced by the specified token.

IMetaDataEmit::DeleteToken Method

Deletes the specified token from the current metadata scope.

IMetaDataEmit::GetSaveSize Method

Gets the estimated binary size of the assembly in the current scope.

IMetaDataEmit::GetTokenFromSig Method

Gets a token for the specified metadata signature.

IMetaDataEmit::GetTokenFromTypeSpec Method

Gets a metadata token for the type with the specified metadata signature.

IMetaDataEmit::Merge Method

Adds the specified imported scope to the list of scopes to be merged.

IMetaDataEmit::MergeEnd Method

Merges into the current scope all the metadata scopes specified by one or more prior calls to IMetaDataEmit::Merge Method.

IMetaDataEmit::Save Method

Saves all metadata in the current scope to the file at the specified address.

IMetaDataEmit::SaveToMemory Method

Saves all metadata in the current scope to the specified area of memory.

IMetaDataEmit::SaveToStream Method

Saves all metadata in the current scope to the specified IStream.

IMetaDataEmit::SetClassLayout Method

Sets or updates the class layout signature of a type defined by a prior call to IMetaDataEmit::DefineTypeDef Method.

IMetaDataEmit::SetCustomAttributeValue Method

Sets or updates the value of a custom attribute defined by a prior call to IMetaDataEmit::DefineCustomAttribute Method.

IMetaDataEmit::SetEventProps Method

Sets or updates the specified feature of an event defined by a prior call to IMetaDataEmit::DefineEvent Method.

IMetaDataEmit::SetFieldMarshal Method

Sets the PInvoke marshaling information for the field, method return, or method parameter referenced by the specified token.

IMetaDataEmit::SetFieldProps Method

Sets or updates the default value for the field referenced by the specified field token.

IMetaDataEmit::SetFieldRVA Method

Sets a global variable value for the relative virtual address of the field referenced by the specified token.

IMetaDataEmit::SetHandler Method

Sets the method referenced by the specified IUnknown pointer as a notification callback for token remaps.

IMetaDataEmit::SetMethodImplFlags Method

Sets or updates the metadata signature of the inherited method implementation referenced by the specified token.

IMetaDataEmit::SetMethodProps Method

Sets or updates the feature, stored at the specified relative virtual address, of a method defined by a prior call to IMetaDataEmit::DefineMethod Method.

IMetaDataEmit::SetModuleProps Method

Updates references to a module defined by a prior call to IMetaDataEmit::DefineModuleRef Method.

IMetaDataEmit::SetParamProps Method

Sets or changes features of a method parameter that was defined by a prior call to IMetaDataEmit::DefineParam Method.

IMetaDataEmit::SetParent Method

Establishes that the specified member, as defined by a prior call to IMetaDataEmit::DefineMemberRef Method, is a member of the specified type, as defined by a prior call to IMetaDataEmit::DefineTypeDef Method.

IMetaDataEmit::SetPermissionSetProps Method

Sets or updates features of the metadata signature of a permission set defined by a prior call to IMetaDataEmit::DefinePermissionSet Method.

IMetaDataEmit::SetPinvokeMap Method

Sets or changes features of a method's PInvoke signature, as defined by a prior call to IMetaDataEmit::DefinePinvokeMap Method.

IMetaDataEmit::SetPropertyProps Method

Sets the features stored in metadata for a property defined by a prior call to IMetaDataEmit::DefineProperty Method.

IMetaDataEmit::SetRVA Method

Sets the relative virtual address of the specified method.

IMetaDataEmit::SetTypeDefProps Method

Sets features of a type defined by a prior call to IMetaDataEmit::DefineTypeDef Method.

IMetaDataEmit::TranslateSigWithScope Method

Imports an assembly into the current scope and gets a new metadata signature for the merged scope.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: Cor.h

Library: Used as a resource in Mscoree.dll

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Reference

IMetaDataEmit2 Interface

Other Resources

Metadata Interfaces