views:

34

answers:

2

In Spring Framework (both for java and .net) i can use the following definition of objects:

<object id="parentObject" type="Type1" abstract="true">
  <property name="name" value="parent"/>
  <property name="age" value="1"/>
</object>

<object id="childObject" type="Type2" parent="parentObject">
  <property name="name" value="override"/>
  <!-- age will inherit value of 1 from parent -->
</object>

Note for parent attribute. It is a kind of templating (inheriting of configuration definitions)

Definition of this attribute: http://www.springframework.net/docs/1.3.0/reference/html/objects.html#objects-childobjects

What is an equivalent for this in Castle Windsor?

A: 

When you say "inherit configuration definition", are you referring to the property values? You can define a common set of parameters and reference them throughout the config. See the Windsor XML reference and the "parameters" node.

Patrick Steele
No. About properties it is too obvious. I have completely rewrote my question.
Rationalle
+2  A: 

Windsor has ability to define your components in code which is waaaaay more powerful and it's a recommended way. You can do the "parent" trick by extracting the common code to a helper method.

Config in Windsor is considered legacy, and should not be used except for very limited cases, so in reality you shouldn't need that at all.

Krzysztof Koźmic
Thank you. Will switch to defining components in the code. But for what cases we still need to use xml config? Do you use xml config for <properties />? If not, where you define constants (in <appConfig />, in code, ...)?
Rationalle
generally I use appConfig for configuration. You might also bind configuration from AppConfig via DictionaryAdapter. See this post for details: http://codebetter.com/blogs/benhall/archive/2010/07/22/improving-testability-with-the-castle-dictionary-adapter.aspx
Krzysztof Koźmic