当前位置: 首页>>代码示例>>C++>>正文


C++ MethodInfo::GetParameters方法代码示例

本文整理汇总了C++中MethodInfo::GetParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodInfo::GetParameters方法的具体用法?C++ MethodInfo::GetParameters怎么用?C++ MethodInfo::GetParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MethodInfo的用法示例。


在下文中一共展示了MethodInfo::GetParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InterceptedFunction

	//*************************************************************************
	// Method:		getManagedDefinition
	// Description: Uses reflection to get information about a managed method
	//
	// Parameters:
	//	fInfo	- structure which contains query data
	//
	// Return Value: (InterceptedFunction) the function definition
	//*************************************************************************
	InterceptedFunction * AddCustIntWizPg2::getManagedDefinition (functionInformation * fInfo)
	{
		
		InterceptedFunction * iFunc = new InterceptedFunction();
		
		//Set the function name
		iFunc->Name = fInfo->functionName;

		//Set the library location name
		iFunc->OriginalDll = Path::GetFileName(fInfo->libraryName);

		//LOAD THE ASSEMBLY TO GET MORE INFORMATION
		Assembly * asmLibrary = Assembly::LoadFrom (fInfo->libraryName);
		
		//Get the module
		Module * asmModule = asmLibrary->GetModule (fInfo->moduleName);

		//Get the type
		Type * moduleType = asmModule->GetType (fInfo->typeName);

		//Get the method 
		if (!fInfo->isConstructor)
		{
			MethodInfo * mi = NULL;
			try
			{
				mi = moduleType->GetMethod (getBaseName(fInfo->functionName), fInfo->bindingFlags, NULL, fInfo->paramTypeArray, NULL);
			}
			catch(...)
			{
				// in case of an exception, just return NULL
				return NULL;
			}

			if (!mi)
				return NULL;

			//Get Parameter Info
			ParameterInfo * paramInfo[] = mi->GetParameters();

			//Set the modifiers
			if (mi->IsPrivate) iFunc->AddTypeModifier ("private");
			if (mi->IsPublic) iFunc->AddTypeModifier ("public");
			if (mi->IsVirtual) iFunc->AddTypeModifier ("virtual");
			if (mi->IsAbstract) iFunc->AddTypeModifier ("abstract");
			if (mi->IsStatic) iFunc->AddTypeModifier ("static");

			//Set return type
			iFunc->ReturnType = mi->ReturnType->ToString();

			//Set Parameter Info
			for (int parCount = 0; parCount < paramInfo->Count; parCount++)
			{
				ParameterInfo * pInfo = paramInfo[parCount];
				InterceptedFunctionParameter * ifParam = new InterceptedFunctionParameter ();
				ifParam->ID = pInfo->Position;
				ifParam->Name = pInfo->Name;
				ifParam->Type = pInfo->ParameterType->FullName;
				ifParam->Access = "";
				if (pInfo->IsIn)
					ifParam->Access = "IN ";
				
				if (pInfo->IsOut)
					ifParam->Access = String::Concat(ifParam->Access, "OUT");
				
				if (ifParam->Access->Length == 0)
					ifParam->Access = "NONE";

				iFunc->AddParameter (ifParam);
			}
		}
		else
		{
			ConstructorInfo * ci = moduleType->GetConstructor (fInfo->bindingFlags, NULL, fInfo->paramTypeArray, NULL);
			
			if (!ci)
				return NULL;

			//Get Parameter Info
			ParameterInfo * paramInfo[] = ci->GetParameters();
	
			//Set the modifiers
			if (ci->IsPrivate) iFunc->AddTypeModifier ("private");
			if (ci->IsPublic) iFunc->AddTypeModifier ("public");
			if (ci->IsVirtual) iFunc->AddTypeModifier ("virtual");
			if (ci->IsAbstract) iFunc->AddTypeModifier ("abstract");
			if (ci->IsStatic) iFunc->AddTypeModifier ("static");

			//Set return type
			iFunc->ReturnType = S"System.Void";

//.........这里部分代码省略.........
开发者ID:IFGHou,项目名称:Holodeck,代码行数:101,代码来源:AddCustIntWizPg2.cpp


注:本文中的MethodInfo::GetParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。