Thursday, March 31, 2011

Using ninject/autofac for a given scenario

I have some providers, say -

<Providers>
    <Provider Type="Providers.IM"  Name="Im"/>
    <Provider Type="Providers.Web" Name="Web"/>
    ...
</Provider>

Each of these providers can give me a session :

<Sessions>
    <Session Name="GoogleIM" Provider="Im"  URL="..." />
    <Session Name="YahooIM"  Provider="Im"  URL="..." />
    <Session Name="YahooWeb" Provider="Web" URL="..." />
    ...
</Session>

Currently, I instantiate "named" sessions by looking at the provider, instantiating the type, and injecting the URL (manually).

I could use a session factory, which would probably have to understand the url and return a proper session.

Is there a way to handle this more elegantly/simply with ninject/autofac?

From stackoverflow

0 comments:

Post a Comment