> For what it's worth what I'm trying to do is allow the user to specify a
> delivery agent (something capable of transfering data from point to point,
> email, FTP, http etc) so in an XML file/database they're allowed to have
> something like <AGENT>FTP</AGENT> or <AGENT>EMAIL</AGENT> (a little bit
more
> complicated than this but in the COM world this was a moniker string)

In your example, I assume that there is a AGENT interface. If this is true,
couldn't you use this:

IAgent myAgent =
(IAgent)System.Reflection.Assembly.Load("mycorp.emailagent");

>
> we simply passed this string to getobject and we had a delivery agent. now
> in .Net we can't do it that way anymore so we have a class factory that
maps
> the names of agents to assembly and classes within the assembly. Is this
to
> best solution.

Are you talking about mapping a simple name to a class name? So if you asked
for an "EMAIL" object, you would get an instance of RR.Agent.Email? This
seems like a perfect place for attributes and reflection. I'm not an expert
on attributes, but if you were to mark your class with the agent name you
wanted, you could then use reflection in your factory to find the class with
a particular agent name.

Erick

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to