Ian Thanks very much for the info.
The hundreds of objects per second I referred to is actually the number of items I can retrieve and process from the AD, not how quick the constructor is. I've thought of another way that doesn't involve code generation. Your post made me look closer at what I was currently doing - registering a type with the factory, storing them in a hashtable along with other criteria (actually multiple hashtables but thats another complication) and then creating an object from the type when the criteria are met. However instead of storing the type, I can store an instance of the class instead and have an internal Clone() method (which uses object.MemberwiseClone) at the root of the target object hierachy. The factory can then call this method to make a usable copy from the 'template'. Advantages: No need to do anything special on the derived classes. Simple to change the register method to accept an object rather than type. No need to get complicated with generated-on-the-fly code. Can delete the big if-then-else routine. For reference, I compared some other options to create 1 million instance of a sample class: new 0.303 seconds Activator.CreateInstance(Type) 3.528 seconds ~ 11.6 times longer (don't know where I got the 50x slower from previously) ConstructorInfo 2.609 seconds ~ 8.6 times longer MemberwiseClone 0.452 seconds ~ 1.5 times longer 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
