2

I have some types like ParentClassA and ParentClassB, with their constructor having parameter as IEumerable<IType>, like shown in the code below.

    public interface IType
    { }
    public class TypeA : IType
    { }
    public class TypeB : IType
    { }
    public class ParentClassA
    {
        public ParentClassA(IEnumerable<IType> obj)
        {
            var d = obj;
        }
    }

    public class ParentClassB
    {
        public ParentClassB(IEnumerable<IType> obj)
        {
            var d = obj;
        }
    }

Now in Structuremap registry,(The version of Structuremap dll is 3.1.5.0) I want to setup the enumerables based on the context, means based on the parent object being created, something like,

For<IEnumerable<IType>>().Use(x => ff(x)).AlwaysUnique();

public IEnumerable<IType> ff(StructureMap.IContext x)
    {
        if (x.RootType.Name.Equals(typeof(ParentClassA).Name))
            return new List<IType>{ new TypeA() };
        else return new List<IType> { new TypeA() };
    }

but when I run the application(it builds fine), in the constructor of ParentClassA etc., I can only see an empty list being passed, but what I am expecting is the return list from function ff.

Please suggest. Thanks.

Tiju John
  • 933
  • 11
  • 28

0 Answers0