本文整理汇总了C++中qcall::ModuleHandle::GetAssembly方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleHandle::GetAssembly方法的具体用法?C++ ModuleHandle::GetAssembly怎么用?C++ ModuleHandle::GetAssembly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qcall::ModuleHandle
的用法示例。
在下文中一共展示了ModuleHandle::GetAssembly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadInMemoryTypeByName
FCIMPLEND
//**************************************************
// LoadInMemoryTypeByName
// Explicitly loading an in memory type
// <TODO>@todo: this function is not dealing with nested type correctly yet.
// We will need to parse the full name by finding "+" for enclosing type, etc.</TODO>
//**************************************************
void QCALLTYPE COMModule::LoadInMemoryTypeByName(QCall::ModuleHandle pModule, LPCWSTR wszFullName)
{
QCALL_CONTRACT;
TypeHandle typeHnd;
BEGIN_QCALL;
if (!pModule->IsReflection())
COMPlusThrow(kNotSupportedException, W("NotSupported_NonReflectedType"));
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
// it is ok to use public import API because this is a dynamic module anyway. We are also receiving Unicode full name as
// parameter.
IMetaDataImport * pImport = pRCW->GetRWImporter();
if (wszFullName == NULL)
IfFailThrow( E_FAIL );
// look up the handle
mdTypeDef td;
HRESULT hr = pImport->FindTypeDefByName(wszFullName, mdTokenNil, &td);
if (FAILED(hr))
{
if (hr != CLDB_E_RECORD_NOTFOUND)
COMPlusThrowHR(hr);
// Get the UTF8 version of strFullName
MAKE_UTF8PTR_FROMWIDE(szFullName, wszFullName);
pModule->GetAssembly()->ThrowTypeLoadException(szFullName, IDS_CLASSLOAD_GENERAL);
}
TypeKey typeKey(pModule, td);
typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());
END_QCALL;
return;
}
示例2: GetMemberRef
//******************************************************************************
//
// GetMemberRefToken
// This function will return a MemberRef token given a MethodDef token and the module where the MethodDef/FieldDef is defined.
//
//******************************************************************************
INT32 QCALLTYPE COMModule::GetMemberRef(QCall::ModuleHandle pModule, QCall::ModuleHandle pRefedModule, INT32 tr, INT32 token)
{
QCALL_CONTRACT;
mdMemberRef memberRefE = 0;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE( pRCW );
LPCUTF8 szName;
ULONG cbComSig;
PCCOR_SIGNATURE pvComSig;
if (TypeFromToken(token) == mdtMethodDef)
{
IfFailThrow(pRefedModule->GetMDImport()->GetNameOfMethodDef(token, &szName));
IfFailThrow(pRefedModule->GetMDImport()->GetSigOfMethodDef(token, &cbComSig, &pvComSig));
}
else
{
IfFailThrow(pRefedModule->GetMDImport()->GetNameOfFieldDef(token, &szName));
IfFailThrow(pRefedModule->GetMDImport()->GetSigOfFieldDef(token, &cbComSig, &pvComSig));
}
MAKE_WIDEPTR_FROMUTF8(wzName, szName);
// Translate the method sig into this scope
//
Assembly * pRefedAssembly = pRefedModule->GetAssembly();
Assembly * pRefingAssembly = pModule->GetAssembly();
if (pRefedAssembly->IsCollectible() && pRefedAssembly != pRefingAssembly)
{
if (pRefingAssembly->IsCollectible())
pRefingAssembly->GetLoaderAllocator()->EnsureReference(pRefedAssembly->GetLoaderAllocator());
else
COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleBoundNonCollectible"));
}
SafeComHolderPreemp<IMetaDataAssemblyEmit> pAssemblyEmit;
IfFailThrow( pRefingAssembly->GetManifestModule()->GetEmitter()->QueryInterface(IID_IMetaDataAssemblyEmit, (void **) &pAssemblyEmit) );
CQuickBytes qbNewSig;
ULONG cbNewSig;
IfFailThrow( pRefedModule->GetMDImport()->TranslateSigWithScope(
pRefedAssembly->GetManifestImport(),
NULL, 0, // hash value
pvComSig,
cbComSig,
pAssemblyEmit, // Emit assembly scope.
pRCW->GetEmitter(),
&qbNewSig,
&cbNewSig) );
mdTypeRef tref;
if (TypeFromToken(tr) == mdtTypeDef)
{
// define a TypeRef using the TypeDef
DefineTypeRefHelper(pRCW->GetEmitter(), tr, &tref);
}
else
tref = tr;
// Define the memberRef
IfFailThrow( pRCW->GetEmitter()->DefineMemberRef(tref, wzName, (PCCOR_SIGNATURE) qbNewSig.Ptr(), cbNewSig, &memberRefE) );
END_QCALL;
// assign output parameter
return (INT32)memberRefE;
}