I am trying to connect a series of decorators using a structural map, but I have some problems.
I read this question , which brought me to such an extent that I can have one decorated class, but I cannot get several decorator levels to work, I have class A that takes a connection string as a parameter, and then class B and class C, which are like decorators for class A. I can get a structure structure to create B that wraps A, but I can't get C wrapping B wrapping a.
This works for level 1:
For<IQuestionRepository> () .Use<LinqToSqlQuestionRepository> () .Ctor<string>("connectionString") .Is(x=>System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString) .EnrichWith (x=>new RecentQuestionCachedRepository(x))
and I thought that just adding another EnrichWith would work like this:
For<IQuestionRepository> () .Use<LinqToSqlQuestionRepository> () .Ctor<string>("connectionString") .Is(x=>System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString) .EnrichWith (x=>new RecentQuestionCachedRepository(x)) .EnrichWith (y=>new FeaturedQuestionCachedRepository(y));
but it just gives me a FeaturedQuestionCachedRepository that wraps the LinqToSqlQuestionRepository, but RecentQuestionCachedRepository is not anywhere on the stack.
What am I doing wrong?
source share