PostSharpAPI ReferencePost­Sharp.​ReflectionReflection­ExtensionsGet­Automatic­Property
Open sandboxFocus

ReflectionExtensions.GetAutomaticProperty Method

GetAutomaticProperty(FieldInfo)

Gets the PropertyInfo whose a given field is the backing field from the current type or base types.

Declaration
public static PropertyInfo GetAutomaticProperty(this FieldInfo field)
Parameters
Type Name Description
FieldInfo field

A field.

Returns
Type Description
PropertyInfo

The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.

GetAutomaticProperty(FieldInfo, Boolean)

Gets the PropertyInfo whose a given field is the backing field and specifies whether base types should be considered.

Declaration
public static PropertyInfo GetAutomaticProperty(this FieldInfo field, bool inherit)
Parameters
Type Name Description
FieldInfo field

A field.

Boolean inherit

true if the property should be looked for in the base, otherwise false.

Returns
Type Description
PropertyInfo

The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.