PostSharpAPI ReferencePost­Sharp.​Patterns.​Dynamic­AdvisingDynamic­Advising­ServicesQuery­Interface
Open sandboxFocus

Method QueryInterface

QueryInterface<T>(Object, Boolean)

Gets the implementation of a specified interface for the specified object.

public static T QueryInterface<T>(object obj, bool throwing = true)
where T : class
Type Name Description
Object obj

The object for which the interface should be queried.

Boolean throwing

true if the method should throw a InvalidCastException if obj does not implement the T interface, false if null be returned instead. The default value is true.

Type Description

An object implementing the T interface on behalf of obj, or null if obj does not implement T and throwing is true.

Type Parameters
Name Description

The type of the required interface.