I do get 7. I wasn't aware it propagates. The example is simple, the real issue is this bug? breaks a lot of situations. I have an application which loads a tcp socket wrapper from XML configuration. But also the same wrapper can be initialized from runtime parameters. Unfortunately, I cannot override the XML settings. I hacked around it, but I already hit an issue with to much components and their quirks.
On Jan 14, 6:02 pm, alwin <alw...@gmail.com> wrote: > But myParam matches to the ctor parameter for MyClass, but it can't > convert it to an int. Should this be ignored? I don't know... > > Inline dependencies are for 'child' components too afaik. > What happens if you do > new { myParam = 7} > (and put the ${} back in the config) > > On Jan 14, 10:11 am, Felix Gartsman <garts...@gmail.com> wrote: > > > I get 7 as expected. Also changing new { myParam2 = new MyClass(7)} to > > new { myParam = new MyClass(7)} I get exception "Cannot convert > > 'MyClass' to 'Int32'" insted of getting the default registered > > 'MyClass' and the unmatching parameter ignored. > > > On Jan 13, 11:10 pm, hammett <hamm...@gmail.com> wrote: > > > > Your code seems right. It all comes down to the precedence order of > > > overrides vs inline dependencies. The inline dependencies support > > > seems half-baked.. > > > What happens if you remove the ${} from the config file? > > > > On Tue, Jan 13, 2009 at 9:16 AM, Felix Gartsman <garts...@gmail.com> > > > wrote: > > > > > Hi, > > > > Could someone clarify what I'm doing wrong here? As an example > > > > consider 2 dummy classes: > > > > internal class MyClass > > > > { > > > > private readonly int myParam; > > > > public MyClass(int myParam) > > > > { > > > > this.myParam = myParam; > > > > } > > > > public int MyParam > > > > { get { return this.myParam; } } > > > > } > > > > > internal class MyClass2 > > > > { > > > > private readonly MyClass myParam2; > > > > public MyClass2(MyClass myParam2) > > > > { > > > > this.myParam2 = myParam2; > > > > } > > > > public MyClass MyParam2 > > > > { get { return this.myParam2; } } > > > > } > > > > > I register them via XML: > > > > <component > > > > id="MyClassA" type="CastleScratch.MyClass, CastleScratch" > > > > lifestyle="transient"> > > > > <parameters> > > > > <MyParam>5</MyParam> > > > > </parameters> > > > > </component> > > > > > <component > > > > id="MyClassB" type="CastleScratch.MyClass2, CastleScratch" > > > > lifestyle="transient"> > > > > <parameters> > > > > <MyParam2>${MyClassA}</MyParam2> > > > > </parameters> > > > > </component> > > > > > Now I resolve: > > > > MyClass2 t = IoC.Resolve<MyClass2>("MyClassB", new { myParam2 = new > > > > MyClass(7)}); > > > > > But t.MyParam2.MyParam==5. Why the override fails, or what I'm > > > > missing? > > > > > Felix. > > > > -- > > > Cheers, > > > hammetthttp://hammett.castleproject.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---