Turn off property injection/resolution

410 views
Skip to first unread message

Ryan Cromwell

unread,
Jan 27, 2010, 12:15:47 PM1/27/10
to castle-pro...@googlegroups.com

I have a Component with a read/writable property that is of a registered component type.  Windsor is trying to resolve this as a dependency even though it is not.  I really don’t want property injection at all (right now at least).  Can I turn this form of resolution off entirely?

 

Thanks,

Ryan

 

 

Krzysztof Koźmic

unread,
Jan 27, 2010, 12:45:08 PM1/27/10
to castle-pro...@googlegroups.com
Ryan - yes you can.

You can either use DoNotWire attribute on properties you don't want to wire, or set model.InspectionBehavior to PropertiesInspectionBehavior.None if you want none of your properties on that component to be injected

Krzysztof
--
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-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

Ryan Cromwell

unread,
Jan 27, 2010, 1:24:25 PM1/27/10
to castle-pro...@googlegroups.com
Thanks Krzysztof,

Is there a way at that in the AllTypes registration syntax? I've tried a
custom facility setting this property in both the ComponentModelCreated
event and the ComponentRegistered event with no luck.

winmail.dat

Ayende Rahien

unread,
Jan 27, 2010, 1:30:05 PM1/27/10
to castle-pro...@googlegroups.com
You can write a facility that would remove the property inspector globally.

Krzysztof Koźmic

unread,
Jan 27, 2010, 1:30:29 PM1/27/10
to castle-pro...@googlegroups.com
There's no _nice_ way in Windsor itself. You can use AttributeDescriptor
IIRC.

There's also a custom facility in contrib that does that:
http://using.castleproject.org/display/Contrib/Castle.Facilities.OptionalPropertyInjection

cheers,
Krzysztof

Ayende Rahien

unread,
Jan 27, 2010, 1:37:31 PM1/27/10
to castle-pro...@googlegroups.com
Sure there is.

windsor.Kernel.ComponentModelBuilder.RemoveContributor(
windsor.Kernle.ComponentModelBuilder.Contributors.OfType<PropertiesDependenciesModelInspector>().Single()
);

2010/1/27 Krzysztof Koźmic <krzyszto...@gmail.com>

Ryan Cromwell

unread,
Jan 27, 2010, 1:40:42 PM1/27/10
to castle-pro...@googlegroups.com

Which kernel event is best to do that in for the facility?  I had been setting the InspectionBehavior, but it seems to have no affect (in ComponentCreated and/or ComponentRegistered).

Ayende Rahien

unread,
Jan 27, 2010, 1:42:34 PM1/27/10
to castle-pro...@googlegroups.com
var windsor = new WindsorContainer();
// that code

// the rest.

Ryan Cromwell

unread,
Jan 27, 2010, 1:43:04 PM1/27/10
to castle-pro...@googlegroups.com

Never mind.  Just did it in Faciliities Init method and we’re golden.

 

Thanks guys.

Krzysztof Koźmic

unread,
Jan 27, 2010, 1:49:14 PM1/27/10
to castle-pro...@googlegroups.com
Yes, as long as you want to do it per container.
If you want more fine grained control, this is not helpful


On 2010-01-27 19:37, Ayende Rahien wrote:
Sure there is.

windsor.Kernel.ComponentModelBuilder.RemoveContributor(
windsor.Kernle.ComponentModelBuilder.Contributors.OfType<PropertiesDependenciesModelInspector>().Single()
);

2010/1/27 Krzysztof Ko�mic <krzyszto...@gmail.com>
There's no _nice_ way in Windsor itself. You can use AttributeDescriptor IIRC.

There's also a custom facility in contrib that does that: http://using.castleproject.org/display/Contrib/Castle.Facilities.OptionalPropertyInjection

cheers,
Krzysztof


On 2010-01-27 19:24, Ryan Cromwell wrote:
Thanks Krzysztof,



Is there a way at that in the AllTypes registration syntax? �I've tried a

custom facility setting this property in both the ComponentModelCreated
event and the ComponentRegistered event with no luck.



From: castle-pro...@googlegroups.com
[mailto:castle-pro...@googlegroups.com] On Behalf Of Krzysztof Kozmic
Sent: Wednesday, January 27, 2010 12:45 PM
To: castle-pro...@googlegroups.com
Subject: Re: Turn off property injection/resolution



Ryan - yes you can.

You can either use DoNotWire attribute on properties you don't want to wire,
or set model.InspectionBehavior to PropertiesInspectionBehavior.None if you
want none of your properties on that component to be injected

Krzysztof


On 2010-01-27 18:15, Ryan Cromwell wrote:

I have a Component with a read/writable property that is of a registered
component type. �Windsor is trying to resolve this as a dependency even
though it is not. �I really don't want property injection at all (right now
at least). �Can I turn this form of resolution off entirely?



Thanks,

Ryan





ďż˝

--
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-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

Reply all
Reply to author
Forward
0 new messages