Actually it feels to me more like you're looking after custom lifestyle. So that all instances of A get single instance of PD, all instances of B get single, but different instance of PD, etc... is that correct?
2010/4/4 Mauricio Scheffer <[email protected]>: > Like this? > > Component.For<PD>().Named("PDA") > Component.For<PD>().Named("PDB") > Component.For<A>().LifeStyle.Transient.ServiceOverrides(ServiceOverride.ForKey("pd").Eq("PDA")) > Component.For<B>().LifeStyle.Transient.ServiceOverrides(ServiceOverride.ForKey("pd").Eq("PDB")) > > On Apr 3, 12:11 am, Bailey Ling <[email protected]> wrote: >> That would work, if I only needed B once. >> >> I'm gonna usehttp://managedesent.codeplex.com/(did you know Windows has a >> built in object database?!?) for local persistance. The >> PersistantDictionary takes in a string argument, which is the directory path >> for where the database files are stored. >> >> I guess this is only half the question. What I'm trying to accomplish is a >> single instance of PersistantDictionary per dependency. >> >> So if both A and B required a PD, I'd like all transients instances of A to >> get the "single" instance of PD/A, and all transients of B would get the >> single instance PD/B. Does that make a little more sense? >> >> Thanks! >> >> On Fri, Apr 2, 2010 at 5:22 PM, Mauricio Scheffer < >> >> >> >> [email protected]> wrote: >> > Component.For<B>() >> > Component.For<A>().Parameters(Parameter.ForKey("name").Eq(typeof(B).Name)) >> >> > but I'm guessing that's not what you really want, right? Can you >> > further explain what you're trying to achieve? >> >> > -- >> > Mauricio >> >> > On Apr 2, 5:13 pm, bling <[email protected]> wrote: >> > > class A { >> > > public A(string name) { } >> >> > > } >> >> > > class B { >> > > public B() { >> > > _a = new A(typeof(B).Name); >> > > } >> >> > > } >> >> > > Basically, that's what I'm trying to accomplish. B has a dependency >> > > on A, but I'd like A's name to be injected with the class name of B. >> > > So it's sort of like a circular dependency, but not directly. >> >> > > ServiceOverrides, DependsOn, and DynamicProperties don't have any >> > > information about who is requesting the component. The Factory >> > > facility supplies the CreationContext, but if I use that then I need >> > > to manually bake in other built-in features like interceptors. >> >> > > Short of writing a sub resolver is there a way to do what I want with >> > > fluent configuration? Thanks. >> >> > -- >> > 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]<castle-project-users%2Bun >> > [email protected]> >> > . >> > For more options, visit this group at >> >http://groups.google.com/group/castle-project-users?hl=en. > > -- > 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. > > -- 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.
