Passing List of Strings or Array of strings into Unity Injection Constructor (Config-Based)

Posted by miguel on Stack Overflow See other posts from Stack Overflow or by miguel
Published on 2010-05-01T10:52:13Z Indexed on 2010/05/01 10:57 UTC
Read the original article Hit count: 958

Filed under:
|
|
|

I cannot seem to get unity working when attempting to pass in an array of strings into a constructor parameter list, while using XML configuration.

When I try the following:

<typeConfig ...>
  <constructor ...>
    <param ... parameterType="System.String[]">
     <array>    
      <value.../>
      <value.../>
     </array>
    </param> 
  </constructor>
</typeConfig>

for a c'tor which looks like this:

void Foo(string[] inputParams_){ ... }

It always fails in Unity's FindConstructor(...) method stating that it cannot find a c'tor mathcing the parameter type of String.String

Does anyone know how to pass an array of stings successfully into this type of c'tor? If not, how can I do so with a list of strings, if the c'tor were to accept an IList?

Thanks!

© Stack Overflow or respective owner

Related posts about unity

Related posts about c#