M_Cyjb_Reflection_PropertyInfoUtil_PowerDelegate_1 - CYJB/Cyjb GitHub Wiki

PropertyInfoUtil.PowerDelegate 方法 (PropertyInfo, Type, Object)

使用指定的第一个参数,创建用于表示指定静态或实例属性的指定类型的委托。

Namespace: Cyjb.Reflection
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static Delegate? PowerDelegate(
	this PropertyInfo property,
	Type delegateType,
	Object? firstArgument
)

参数

 

property
Type: System.Reflection.PropertyInfo
描述委托要表示的静态或实例属性的 PropertyInfo
delegateType
Type: System.Type
要创建的委托类型。
firstArgument
Type: System.Object
如果是实例属性,则作为委托要绑定到的对象;否则将作为属性的第一个参数。

返回值

Type: Delegate
指定类型的委托,表示访问指定的静态或实例属性。如果无法绑定,则为 null

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型PropertyInfo的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。

Exceptions

 

异常 条件
ArgumentNullException propertynull
ArgumentNullException delegateTypenull
ArgumentException delegateType 不是委托类型。
MethodAccessException 调用方无权访问 property

Remarks

如果委托具有返回值,则认为是获取属性,否则认为是设置属性。 支持参数的强制类型转换,参数声明可以与实际类型不同。

参见

Reference

PropertyInfoUtil 类
PowerDelegate 重载
Cyjb.Reflection 命名空间

⚠️ **GitHub.com Fallback** ⚠️