Castle Windsor Tips – specifying IEnumerable in config file

One of the more obscure things I have had to do inside a Castle config is to specify an IEnumerable<T> instance which required taking the technique I showed in this post a little further:
<component id="MyTypes"
           service="System.Collections.Generic.IEnumerable`1[[Type, Assembly]], mscorlib"
           type="System.Collections.Generic.List`1[[Type, Assembly]], mscorlib"
           lifestyle="singleton">
    <parameters>
        <collection>
            <array>
                <item>${Item1}</item>
                <item>${Item2}</item>
            </array>
        </collection>
    </parameters>
</component>

I specified the lifestyle of this IEnumerable<T> to be singleton as in most cases where you would want to do something like this is to be able to configure something once and use it everywhere, but you should change it to suit your needs.

  • http://www.collegescholarships-tips.org college scholarships

    Great information! I’ve been looking for something like this for a while now. Thanks!