本文整理汇总了C#中System.RuntimeType.GetMember方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeType.GetMember方法的具体用法?C# RuntimeType.GetMember怎么用?C# RuntimeType.GetMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.RuntimeType
的用法示例。
在下文中一共展示了RuntimeType.GetMember方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveOverloadedMethod
private void ResolveOverloadedMethod(RuntimeType t, string methodName, ArrayList argNames, ArrayList argValues)
{
System.Reflection.MethodBase base2;
MemberInfo[] infoArray = t.GetMember(methodName, MemberTypes.Method, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
int length = infoArray.Length;
switch (length)
{
case 1:
this.MI = infoArray[0] as System.Reflection.MethodBase;
return;
case 0:
return;
default:
base2 = null;
for (int i = 0; i < length; i++)
{
System.Reflection.MethodBase base3 = infoArray[i] as System.Reflection.MethodBase;
ParameterInfo[] parameters = base3.GetParameters();
if (parameters.Length == argValues.Count)
{
bool flag = 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())
{
flag = false;
break;
}
}
if (flag)
{
base2 = base3;
break;
}
}
}
break;
}
if (base2 == null)
{
throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
}
this.MI = base2;
}
示例2: 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;
}