C#, Generic factory with support for private constructors

added by sedanwer
12/30/2011 9:27:28 AM

6 Kicks, 414 Views

Shows how-to create a generic factory allowing creation of generic classes having a private constructor using compiled lambdas to get better performance.


12/29/2011 7:07:55 PM
how about a kick it badge, daniel?

12/30/2011 9:28:08 AM
Interesting, but I'm curious as to why a class would have a need for a private constructor? Did the person you were helping give you any hints as to what they were trying to accomplish?

1/2/2012 9:06:22 AM
Not my call, I just provided a solution, but right of my head....

E.g in a deserialization/mapping scenario. Normal consumers should not be "allowed" to use a certain constructor, whilst your tooling that perhaps create an instance and the populate certain members on it.