Home All Groups Group Topic Archive Search About

Question regarding implentation of factory pattern with internal objects

Author
1 Mar 2006 8:56 PM
Carlo Razzeto
I have a question regarding the implementation of a factory design pattern
and objects which are declared at internal scope. Here is my situation:

Currently I'm working on an order processing library which will power a
webservice. I do not want any programmer outside of my libary to be able to
inheret from or even see the objects responcible for processing the order
entry XML, instead I have provided a public sealed class library which
exposes a method which accepts order entry XML. What this method needs to
do, is find the most appropriate order processing class, instantiate it and
pass the order entry data to it. However, because all these classes are
internal, with internal constructors, Activator.CreateInstance() will not be
able to create the objects. So I was wondering if anyone out there had more
advanced knowledge of Reflection than I, and might be able to point me in
the right direction with handling this type of situation.

I'm also running up against a wall with this issue in a database abtraction
library I wrote which publicly exposes the specific database objects,
(should) have internal constructors so end programmers must use the provided
factory method to establish a database connection.

Carlo Razzeto

Author
1 Mar 2006 9:39 PM
Carlo Razzeto
Update,
As far as my first situation, I was able to get around the problem by
keeping the class internal, but the constructor public. I really see this as
being a bit of a hack solution, but it's about the best I got right now
because I can't create these objects based on a switch statement, the
possiblity that we will be adding new objects often enough to make this
impractical is too great. I guess the DB libary I could use a switch
statment as that should be fairly constant, but it'd still be nice to have a
more automated solution.


Show quote
"Carlo Razzeto" <crazz***@hotmail.com> wrote in message
news:OqbAwKXPGHA.420@tk2msftngp13.phx.gbl...
>I have a question regarding the implementation of a factory design pattern
>and objects which are declared at internal scope. Here is my situation:
>
> Currently I'm working on an order processing library which will power a
> webservice. I do not want any programmer outside of my libary to be able
> to inheret from or even see the objects responcible for processing the
> order entry XML, instead I have provided a public sealed class library
> which exposes a method which accepts order entry XML. What this method
> needs to do, is find the most appropriate order processing class,
> instantiate it and pass the order entry data to it. However, because all
> these classes are internal, with internal constructors,
> Activator.CreateInstance() will not be able to create the objects. So I
> was wondering if anyone out there had more advanced knowledge of
> Reflection than I, and might be able to point me in the right direction
> with handling this type of situation.
>
> I'm also running up against a wall with this issue in a database
> abtraction library I wrote which publicly exposes the specific database
> objects, (should) have internal constructors so end programmers must use
> the provided factory method to establish a database connection.
>
> Carlo Razzeto
>

AddThis Social Bookmark Button