Get assembly interface implementations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joachim

    Get assembly interface implementations

    Is there a way to get the names of all classes that implements a certain
    interface from an assembly?
  • Stoitcho Goutsev \(100\)

    #2
    Re: Get assembly interface implementations

    Joachim,

    There is no direct method, but it is still pretty straightgforwar d to
    implement.

    Assembly.GetTyp es return array of Type object for types declared in the
    assembly. Once you have this array you need to filter out all types that
    implement that inteface. To do that you can go throught all Type objects in
    the array and using one of the fillowing methods:

    Type.GetInterfa ce("<interface name>") and check the return value against
    *null*

    or

    typeof(<interfa ce name>).IsAssign ableFrom(<type object from the
    collection>) - In this case *true* indicates that the type represented by
    Type object from the array implements specified interface.


    --
    HTH
    Stoitcho Goutsev (100)
    "Joachim" <Joachim@discus sions.microsoft .comwrote in message
    news:1717B8BE-B763-4038-B286-76F1DAE9EB3D@mi crosoft.com...
    Is there a way to get the names of all classes that implements a certain
    interface from an assembly?

    Comment

    Working...