M_Cyjb_Reflection_PowerBinder_SelectMethod - CYJB/Cyjb GitHub Wiki
基于参数类型,从给定的方法集中选择一个方法。 允许通过指定 OptionalParamBinding 来匹配可选参数。
Namespace: Cyjb.Reflection
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6
C#
public override MethodBase? SelectMethod(
BindingFlags bindingAttr,
MethodBase[] match,
Type[] types,
ParameterModifier[]? modifiers
)
- bindingAttr
- Type: System.Reflection.BindingFlags
BindingFlags 值的按位组合。 - match
- Type: System.Reflection.MethodBase[]
用于匹配的候选方法集。 - types
- Type: System.Type[]
用于定位匹配方法的参数类型。 - modifiers
- Type: System.Reflection.ParameterModifier[]
使绑定能够处理在其中修改了类型的参数签名的参数修饰符数组。
Type: MethodBase
如果找到,则为匹配的方法;否则为 null
。
异常 | 条件 |
---|---|
ArgumentNullException |
match 为 null 。 |
ArgumentNullException |
types 为 null 。 |
ArgumentException | match 为空数组。 |
ArgumentException |
match 中包含为 null 的元素。 |
AmbiguousMatchException | match 包含多个与 types 匹配程度相同的方法。 |
此方法支持可选参数,可以通过为参数类型指定 Missing 来表示使用可选参数。 或者为 bindingAttr 设置 InvokeMethod、 CreateInstance、GetProperty 或 SetProperty 之一,就可以直接省略掉可选参数对应的类型。