xml is the most flexible approach, but how much flexibility do you
need? another way to approach it: xml is ideal for configuration
settings that change for each deployment. if the functionality/
implementations do not change between deployment then fluent
registration will be easier to maintain.
you can even combine xml configs with fluent registration. here is a
simple example
new WindsorContainer(new XmlInterpreter())
.AddComponent<IFoo, Foo>("foo")
.AddComponent<IBar, Bar>("bar");
xml
<castle>
<components>
<component id="foo">
<parameters>
<answer>42<answer>
</parameters>
</component>
</components>
</castle>
class Foo : IFoo
{
public Foo(IBar bar, int answer)
{
}
}
when Foo is resolved it will get 42 from the config file and Bar from
the component. And this is just 1 option. there are others as well.
On Sep 3, 10:29 am, "Cesar Sanz" <[email protected]> wrote:
> @Mauricio:> In your type name, the first namespace says "IoCWindor" instead of
> > "IoCWindsor", not sure if that was a typo.
>
> Eagle eye!!!, That was the problem, a typo.. thanks
>
> @Jason:>I would highly recommend the fluent registration to cofigure the
> >container.
>
> I thought xml file was a more flexible approach..
> Has someone else the same opinion about using fluent registration in lieu of
> xml?
>
> Thanks for answering
>
> ----- Original Message -----
> From: "Jason Meckley" <[email protected]>
> To: "Castle Project Users" <[email protected]>
> Sent: Thursday, September 03, 2009 6:20 AM
> Subject: Re: Windsor and Generics
>
> I would highly recommend the fluent registration to cofigure the
> container. writing out an xml is very susceptible to spelling/syntax
> mistakes (as you just encountered) and doesn't play nice with
> refactoring tools like R#.
>
> On Sep 2, 9:18 pm, Mauricio Scheffer <[email protected]>
> wrote:
> > IRepository<T> is C# specific. The backtick notation is not a Windsor
> > invention, it's how the CLR defines generics in a language independent
> > way, seehttp://msdn.microsoft.com/en-us/library/w3f99sx1.aspx
>
> > In your type name, the first namespace says "IoCWindor" instead of
> > "IoCWindsor", not sure if that was a typo.
>
> > Also, the type name defines a "IRepository of OrderRepository" (in C#
> > IRepository<OrderRepository>) which doesn't make sense, you probably
> > want IRepository<Order>.
>
> > Cheers,
> > Mauricio
>
> > On Sep 2, 8:40 pm, "Cesar Sanz" <[email protected]> wrote:
>
> > > Well, I've already read the first link... and the same problem
>
> > > ERROR:
> > > "The type name
> > > IoCWindor.Repository.IRepository`1[[IoCWindsor.Repository.OrderRepository,
> > > IoCWindsor]], IoCWindsor could not be located"
>
> > > I've checked the namespaces, the names of the calss, the assembly name
> > > etc..
> > > and still the same problem.
>
> > > What can me wrong?
>
> > > ----- Original Message -----
> > > From: "John Simons" <[email protected]>
> > > To: "Castle Project Users" <[email protected]>
> > > Sent: Wednesday, September 02, 2009 5:27 PM
> > > Subject: Re: Windsor and Generics
>
> > > For xml registration that is the syntax, more info
> > > here
> > > -http://www.castleproject.org/container/documentation/trunk/usersguide...
>
> > > If you want prettiness, than use fluent
> > > registration
> > > -http://using.castleproject.org/display/IoC/Fluent+Registration+API
>
> > > On Sep 3, 9:08 am, "[email protected]"
> > > <[email protected]> wrote:
> > > > Hello,
>
> > > > Looking for IoC in the Web I Found
> > > > thishttp://msdn.microsoft.com/en-us/library/aa973811(loband).aspx
>
> > > > In that link I see something like this (for generics)
>
> > > > <configuration>
> > > > <components>
> > > > <component id="orders-repository"
> > > > service="NShop.IRepository`1[[NShop.Order, NShop]],
> > > > NShop"
> > > > type="NShop.OrderRepository, NShop"/>
> > > > <component id="generic-repository" service="NShop.IRepository`1,
> > > > NShop"
> > > > type="NShop.NHibernateRepository`1, NShop"/>
> > > > <component id="orders-dispatcher" type="NShop.OrdersDispatcher,
> > > > NShop"/>
> > > > </components>
> > > > </configuration>
>
> > > > The reason for this NShop.IRepository`1[[NShop.Order, NShop]], NShop
> > > > is beacuse it is the representation de
> > > > generics in the CLR (according to ayende)
>
> > > > So NShop.IRepository`1[[NShop.Order, NShop]] = IRepository<T>
>
> > > > It looks ugly to me (why not make the configuration to work with the
> > > > IRepository<T> style?) ,
> > > > but, this is not the case..
> > > > The point is that when I run the code, an exception is thrown
> > > > indicating an error in configuration file for that strange line
> > > > service="NShop.IRepository`1[[NShop.Order, NShop]], NShop"
>
> > > > The lesson exposed in that link is old (2006)
> > > > My question is... How do I manage Generics using the new Windsor (2009
> > > > assemblies)?
>
> > > > Slts
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---