Populate collection

Nov 9, 2009 at 8:21 AM

I've got a class that exposes a public member of a collection type, let's say a list. This property is read only, that is: it is possible to populate it by calling its "Add" method, but it's not possible to assign a populated list to that member variable. Here's an example:

public class A{

  public A(){

thi.List=new List<string>();


public List<string> List{


private set;




How can I inject an object of type A, with its "List" property populated?

Note: I don't want to modify the class!



Dec 18, 2009 at 12:52 AM

You don't, unfortunately, without some custom code in a container extension to do it. This isn't something we support out of the box.

Dec 18, 2009 at 6:52 AM
What a pity!

Such enhancement would be nice...

Thanks, anyway!