Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What's happening (from what I can see) is that the ticks property is being incorrectly identified as a compulsory parameter (because it belongs to the constructor with the least number of arguments) even though all value types have a default parameter-less constructor.</p> <p>However the constructor candidate matching the most parameters will still be selected even if you supply additional parameters (i.e. ticks) so you can work around this by just including ticks in the list of parameters:</p> <pre><code>&lt;component id="timeInForce"" type="System.TimeSpan, mscorlib"&gt; &lt;parameters&gt; &lt;ticks&gt;0&lt;/ticks&gt; &lt;hours&gt;0&lt;/hours&gt; &lt;minutes&gt;15&lt;/minutes&gt; &lt;seconds&gt;0&lt;/seconds&gt; &lt;/parameters&gt; &lt;/component&gt; </code></pre> <p>Here is a quick test to verify it works (which passes for against the castle trunk):</p> <pre><code>string xml = @"&lt;?xml version=""1.0"" encoding=""utf-8"" ?&gt; &lt;castle&gt; &lt;components&gt; &lt;component id=""timeInForce"" type=""System.TimeSpan, mscorlib""&gt; &lt;parameters&gt; &lt;ticks&gt;0&lt;/ticks&gt; &lt;hours&gt;0&lt;/hours&gt; &lt;minutes&gt;15&lt;/minutes&gt; &lt;seconds&gt;0&lt;/seconds&gt; &lt;/parameters&gt; &lt;/component&gt; &lt;/components&gt; &lt;/castle&gt;"; WindsorContainer container = new WindsorContainer( new XmlInterpreter(new StaticContentResource(xml))); TimeSpan span = container.Resolve&lt;TimeSpan&gt;("timeInForce"); Assert.AreEqual(new TimeSpan(0, 15, 0), span); </code></pre> <p>However, what I would suggest rather then the approach your using is to implement your own type converter, as discussed in the <a href="http://www.castleproject.org/container/documentation/trunk/usersguide/typeconverters.html" rel="nofollow noreferrer">castle documentation</a>.</p> <p>That way you could develop your own shorthand form for a timespan i.e. "15m" or "2h15m" or whatever takes your fancy - making your config a little easier to read and maintain and working round the issues you're currently experiencing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload