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 <[email protected]> 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 <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---