Determine Object Type From Database

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

All,

I am working on an application that allows users to track
various items for various clients. For example Client A
may have an object Box where Client B has an object
Canister. When a user goes to enter a new object I would
like the application to determine what objects are
available based upon the client (easy enough) and when
they determine what object to enter the program would know
that it needed to instantiate an object of that type. For
example, the user selects Client A and object Box the
program would instantiate an object of type Box. I want to
avoid hardcoding this into the application so that way if
I need to add object of type Carton later on I can insert
that object into the database, distribute a DLL for that
object, and the program would be able to instantate
objects of the type canister.

Does anyone have any idea if this is possible to do and if
so how? Any suggesions would be greatly appreciated.
Thanks!
 
Sounds to me like the database is not a central issue in this problem.
Getting the name of the type from the db is pretty simple, and I'll guess
that is not what is puzzling you.

What you seem to be asking for, is a way to instantiate types, selecting the
implementation of the type dynamically, at runtime.
You can do this via the System.Activator.CreateInstance() method, or via
Reflection with the System.Type.CreateInstance()
Check the archives of this group for tips .

You'll probably want to use interfaces to construct your extensible object
model, and employ a Factory pattern.
eg,
http://www.superdotnet.com/Article.aspx?ArticleID=158

suggestion: google for "factory CreateInstance interface"
 
Back
Top