Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What version of Castle? I recall, from the depths of what goes for my memory at 4am in the morning, that there was a resolution for constructor work in Castle 2.0.</p> <p>Humm, memory coming back a little now... Something tells me that Castle will construct the object with the first public ctor. May be as simple as moving what you want for Castle to load, to the top.</p> <p>If that doesn't work for you, perhaps refactor your code a little? </p> <p>Option 1) Make the first two constructors internal.</p> <p>Option 2) Use a Factory pattern for your complex objects, which will utilize castle on the backend to new up the more simple or complex version.</p> <p>Option 3) Create 3 classes from your base superclass, each having a more complicated constructor. This way, you can specific in the Castle config file exactly which service to load. For example:</p> <pre><code>public abstract class BaseClass { public BaseClass(String requiredParam) { ... } } public class SimpleClass : BaseClass { public SimpleClass(String requiredParam, String anotherParam) : base(requiredParam) { ... } } public class MoreComplexClass : SimpleClass { public MoreComplexClass (String requiredParam, String anotherParam, String yetAnother) : base(requiredParam, anotherParam) { ... } } </code></pre> <p>But, I myself have not run into this yet. Mainly because I stick to only public 1 ctor on my classes, with a few private/internal ctors for things such as Linq to new up my objects with an empty ctor (since Linq doesn't support Dependency Injection, boo).</p> <p>Note that in that last statement, internal ctors, that my SRP (Single Responsiblity Pattern) for resolving my IoC components is external, in a seperate higharchy assembly (i.e. an application or UI layer). Since it not internal to my domain objects, the internal ctors are not seen by Castle.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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