PostSharpAPI ReferencePost­Sharp.​Patterns.​Dynamic­AdvisingIQuery­InterfaceQuery­Interface
Open sandboxFocus

IQueryInterface.QueryInterface Method


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

T QueryInterface<T>()
where T : class
Type Description

An object implementing the T interface on behalf of the current object, or null if the current object does not implement the T interface.

Type Parameters
Name Description

The type of the required interface.


This method shall return the current object if the type of the current object statically implements the interface. Otherwise, the method shall return another object that implements T on behalf of the current object. In this case, the returned object shall implement the IDynamicInterfaceImplementation interface, which allows to navigate back to the current object.

User code typically uses the PostSharp.Patterns.DynamicAdvising.QueryInterfaceExtensions.QueryInterface``1(System.Object,System.Boolean) extension method.