List objects which Implement a particular Interface

  • Thread starter Thread starter johnnyD
  • Start date Start date
J

johnnyD

How would I traverse through a namespace and determine all the object
types that implement an interface.

For instance in the namespace "Microsoft.SqlServer.Management.Smo"
Namespace I want to determine all the Classes/Types which implement
the IScriptable Interface.

I am not looking for anyone to code this for me, as I am trying to
learn the language but any snippets or pointers would be greatly
appreciated.
 
johnnyD said:
How would I traverse through a namespace and determine all the object
types that implement an interface.

For instance in the namespace "Microsoft.SqlServer.Management.Smo"
Namespace I want to determine all the Classes/Types which implement
the IScriptable Interface.

I am not looking for anyone to code this for me, as I am trying to
learn the language but any snippets or pointers would be greatly
appreciated.

You can't easily traverse through a *namespace*, but you can go through
an *assembly*. You'll need to determine which assemblies you're
interested in.

Look at Assembly.GetTypes, Type.GetNamespace, and Type.IsAssignableFrom
for further steps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top