本文整理汇总了C++中qcall::ModuleHandle::LookupAssemblyRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleHandle::LookupAssemblyRef方法的具体用法?C++ ModuleHandle::LookupAssemblyRef怎么用?C++ ModuleHandle::LookupAssemblyRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcall::ModuleHandle
的用法示例。
在下文中一共展示了ModuleHandle::LookupAssemblyRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTypeRef
//**************************************************
// GetTypeRef
// This function will return the type token given full qual name. If the type
// is defined locally, we will return the TypeDef token. Or we will return a TypeRef token
// with proper resolution scope calculated.
// wszFullName is escaped (TYPE_NAME_RESERVED_CHAR). It should not be byref or contain enclosing type name,
// assembly name, and generic argument list.
//**************************************************
mdTypeRef QCALLTYPE COMModule::GetTypeRef(QCall::ModuleHandle pModule,
LPCWSTR wszFullName,
QCall::ModuleHandle pRefedModule,
LPCWSTR wszRefedModuleFileName,
INT32 tkResolutionArg)
{
QCALL_CONTRACT;
mdTypeRef tr = 0;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
IMetaDataEmit * pEmit = pRCW->GetEmitter();
IMetaDataImport * pImport = pRCW->GetRWImporter();
if (wszFullName == NULL) {
COMPlusThrow(kArgumentNullException, W("ArgumentNull_String"));
}
InlineSString<128> ssNameUnescaped;
LPCWSTR wszTemp = wszFullName;
WCHAR c;
while(0 != (c = *wszTemp++))
{
if ( c == W('\\') &&
IsTypeNameReservedChar(*wszTemp) )
{
ssNameUnescaped.Append(*wszTemp++);
}
else
{
_ASSERTE( ! IsTypeNameReservedChar(c) );
ssNameUnescaped.Append(c);
}
}
LPCWSTR wszFullNameUnescaped = ssNameUnescaped.GetUnicode();
Assembly * pThisAssembly = pModule->GetClassLoader()->GetAssembly();
Assembly * pRefedAssembly = pRefedModule->GetClassLoader()->GetAssembly();
if (pModule == pRefedModule)
{
// referenced type is from the same module so we must be able to find a TypeDef.
IfFailThrow(pImport->FindTypeDefByName(
wszFullNameUnescaped,
RidFromToken(tkResolutionArg) ? tkResolutionArg : mdTypeDefNil,
&tr));
}
else
{
mdToken tkResolution = mdTokenNil;
if (RidFromToken(tkResolutionArg))
{
// reference to nested type
tkResolution = tkResolutionArg;
}
else
{
// reference to top level type
if ( pThisAssembly != pRefedAssembly )
{
SafeComHolderPreemp<IMetaDataAssemblyEmit> pAssemblyEmit;
// Generate AssemblyRef
IfFailThrow( pEmit->QueryInterface(IID_IMetaDataAssemblyEmit, (void **) &pAssemblyEmit) );
tkResolution = pThisAssembly->AddAssemblyRef(pRefedAssembly, pAssemblyEmit);
// Add the assembly ref token and the manifest module it is referring to this module's rid map.
// This is needed regardless of whether the dynamic assembly has run access. Even in Save-only
// or Refleciton-only mode, CreateType() of the referencing type may still need the referenced
// type to be resolved and loaded, e.g. if the referencing type is a subclass of the referenced type.
//
// Don't cache if there is assembly associated with the token already. The assembly ref resolution
// can be ambiguous because of reflection emit does not require unique assembly names.
// We always let the first association win. Ideally, we would disallow this situation by throwing
// exception, but that would be a breaking change.
if(pModule->LookupAssemblyRef(tkResolution) == NULL)
{
pModule->ForceStoreAssemblyRef(tkResolution, pRefedAssembly);
}
}
else
{
_ASSERTE(pModule != pRefedModule);
_ASSERTE(wszRefedModuleFileName != NULL);
// Generate ModuleRef
//.........这里部分代码省略.........