本文整理汇总了C++中Assembly::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Assembly::GetType方法的具体用法?C++ Assembly::GetType怎么用?C++ Assembly::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assembly
的用法示例。
在下文中一共展示了Assembly::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInstance
//
// Method: CreateInstance(String* typeName, Object* [])
//
// Purpose: Assembly-savvy invocation of Activator::CreateInstance
Object* InvokeBridge::CreateInstance(TypeName* typeName,
Object* args[]) {
Object* instance = 0;
Type* t = InvokeBridge::GetType(typeName->toStdString());
// Console::WriteLine("x{0} y{1}", typeName->toStdString(), t);
if (!t) {
try {
Assembly* localA = Assembly::LoadFrom(typeName->m_assembly);
t = localA->GetType(typeName->m_class);
} catch (Exception* e) {
;
}
}
if (!t) {
try {
AppDomain* currentDomain = AppDomain::CurrentDomain;
// Assembly* stuff[] = currentDomain->GetAssemblies();
// for (int i=0;i < stuff.Length; i++) {
// Console::WriteLine("x{0} y{1}", stuff[i]->ToString(), stuff[i]->FullName);
// }
// Console::WriteLine("x{0} y{1}", typeName->toStdString(), t);
Assembly* localA = Assembly::LoadWithPartialName("HugsAssembly");
t = localA->GetType(typeName->m_class);
// Console::WriteLine("x{0} y{1}", typeName->toStdString(), t);
} catch (Exception*) {
;
}
}
if (t) {
try {
Object* o =Activator::CreateInstance(t,(Object* [])args);
return o;
} catch (Exception* e) {
Console::WriteLine("Failure: {0}", e);
return 0;
}
}
}
示例2: strrchr
extern "C" LUAMODULE_API int luaopen_dotnet(lua_State* L)
{
LuaState* state = LuaState::CastState(L);
LuaObject obj = state->GetGlobals()["dotnet"];
if (obj.IsTable())
return 0;
obj = state->GetGlobals().CreateTable( "dotnet" );
char path[ _MAX_PATH ];
#ifdef _DEBUG
const char* dllName = "ldotnet.dlld";
#else !_DEBUG
const char* dllName = "ldotnet.dll";
#endif _DEBUG
GetModuleFileName(GetModuleHandle(dllName), path, _MAX_PATH);
char* slashPtr = strrchr( path, '\\' );
slashPtr++;
*slashPtr = 0;
#ifdef _DEBUG
strcat(path, "Debug\\");
#endif _DEBUG
strcat(path, "dotnetinterface.dll");
Assembly* assembly = Assembly::LoadFrom(path);
Type* type = assembly->GetType("LuaInterface.Lua");
Object* parms[] = new Object*[1];
parms[0] = __box((IntPtr)state->GetCState());
Object* lua = Activator::CreateInstance(type, parms);
LuaObject metaTableObj;
metaTableObj.AssignNewTable(state);
metaTableObj.Register("__gc", GCHandle_gc);
LuaObject dotNetObj = state->NewUserDataBox((void*)(GCHandle::op_Explicit(GCHandle::Alloc(lua))).ToInt32());
dotNetObj.SetMetaTable(metaTableObj);
obj.SetObject("__dotNetUserData", dotNetObj);
return 0;
}