Here is my query...

Short description:
Given a Type, I need to be able to create an instance of that Type.
The creation code needs to be as quick as possible (several hundred
creations per second may be required)
Activator.CreateInstance is too slow for this - up to 50 times slower than
a new operation in a simple test.

Long description:
This is a Active Directory library
I have a base factory class which 'knows' about certain AD classes (e.g.
classes from the default schema such as User, Group, OU etc.)
In an ideal world, I would like to be able to register information about
new AD classes and let the factory create them.
But I currently do the following (which works well enough).
- Allow the user to derive a new factory which knows about new classes.
- Have a virtual CreateFromType() method that does a big if-then-else on
the list of types and create them directly
- If it is not found then call the base CreateFromType() method.

However, this will only allow derivation from a single factory and in
theory there may be more than one. It would be preferable to just let the
new classes register themselves with a single factory class.
Would it be possible and/or feasible to create an in-memory assembly (got
this idea from the compiled Regex feature of .NET) consisting of a single
class/method containing a list of if-then-else statements for all of the
registered classes?

I don't want to start looking into this complex (for me at least) scenario
if someone more knowledgeable can say that it won't work.

Cheers
Simon

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
You may be interested in Guerrilla .NET, 24 March 2003, in London
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to