PostSharp.ILAPI ReferencePost­Sharp.​Patterns.​UtilitiesUnknown­Object­AccessorTry­Get­Property
Open sandboxFocus

UnknownObjectAccessor.TryGetProperty Method

TryGetProperty<T>(String, out T)

Gets the value of a named property for the current UnknownObjectAccessor.

Declaration
public bool TryGetProperty<T>(string name, out T value)
Parameters
Type Name Description
String name

Property name.

T value

Returns the property value if a property named name exists and its value can be cast to T, otherwise default.

Returns
Type Description
System.Boolean

true if the property value if a property named name exists and its value can be cast to T, otherwise false.

Type Parameters
Name Description
T

Type of the property value.

TryGetProperty<T>(Object, String, out T)

Gets the value of a named property for an arbitrary object.

Declaration
public static bool TryGetProperty<T>(object instance, string name, out T value)
Parameters
Type Name Description
Object instance

The object whose property has to be returned.

String name

Property name.

T value

Returns the property value if a property named name exists and its value can be cast to T, otherwise default.

Returns
Type Description
System.Boolean

true if the property value if a property named name exists and its value can be cast to T, otherwise false.

Type Parameters
Name Description
T

Type of the property value.