tags:

views:

36

answers:

0

We are currently using profiles and not find ourselves in a situation where we would like to use a combination of profiles at once, obviously we can't do this. I'll give a code example of what we are trying to do:

public class Root
{
    public Root(IAmMoo mooooo)
    {

    }
}

public interface IAmMoo
{

}

public class SomeMoo : IAmMoo{}

public class AnotherMoo : IAmMoo {}

public class MooRegistry : Registry
{
    public MooRegistry()
    {
        ObjectFactory.Initialize(i =>
                                     {
                                         i.ForRequestedType<Root>()
                                             .AddInstances(j =>
                                                               {
                                                                   j.OfConcreteType<Root>()
                                                                       .WithName("Scooby");
                                                               })
                                             .TheDefault.Is.OfConcreteType<Root>();

                                         i.ForRequestedType<IAmMoo>()
                                             .AddInstances(k =>
                                                               {
                                                                   k.OfConcreteType<AnotherMoo>()
                                                                       .WithName("Scooby");
                                                               })
                                             .TheDefault.Is.OfConcreteType<SomeMoo>();
                                     });
    }
}

[TestFixture]
public class MooTest
{
    [Test]
    public void DoItBaby()
    {
        new MooRegistry();

        var x = ObjectFactory.GetNamedInstance<IAmMoo>("Scooby");
    }
}

When I get the named instance I'd like for the class that gets passed into the Root class constructor to be of the type AnotherMoo.

If anyone can help with this it would be very much appreciated.