本文整理汇总了C#中RuntimeType.GetMember方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeType.GetMember方法的具体用法?C# RuntimeType.GetMember怎么用?C# RuntimeType.GetMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuntimeType
的用法示例。
在下文中一共展示了RuntimeType.GetMember方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveOverloadedMethod
// This will find the right overloaded method if the argValues from soap have type information,
// By default parameters will be of type string, this could lead to a wrong choice of methodbase.
void ResolveOverloadedMethod(RuntimeType t, String methodName, ArrayList argNames, ArrayList argValues)
{
MemberInfo[] canidates = t.GetMember(methodName, MemberTypes.Method, MethodCall.LookupPublic);
int canidatesCount = canidates.Length;
if (canidatesCount == 1)
{
MI = canidates[0] as MethodBase;
return;
}
if (canidatesCount == 0)
return;
MethodBase match = null;
for (int i = 0; i < canidatesCount; i++)
{
MethodBase canidate = canidates[i] as MethodBase;
ParameterInfo[] parameters = canidate.GetParameters();
if (parameters.Length == argValues.Count)
{
bool isMatch = true;
for (int j = 0; j < parameters.Length; j++)
{
Type parameterType = parameters[j].ParameterType;
if (parameterType.IsByRef)
parameterType = parameterType.GetElementType();
if (parameterType != argValues[j].GetType())
{
isMatch = false;
break;
}
}
if (isMatch)
{
match = canidate;
break;
}
}
}
if (match == null)
throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
MI = match;
}