Hi there.
I'm trying out the latest build of StructureMap, to learn about IoC containers and the like. As my first test, I have the following class:
public class Hospital
{
private Person Person { get; set; }
private int Level { get; set; }
public Hospital(Person employee, int level)
{
Person = employee;
Level = level;
}
public void ShowId()
{
Console.WriteLine(this.Level);
this.Person.Identify();
}
}
I then use StructureMap like this:
static void Main()
{
ObjectFactory.Configure(x =>
{
x.For<Person>().Use<Doctor>();
x.ForConcreteType<Hospital>().Configure.Ctor<int>().Equals(23);
});
var h = ObjectFactory.GetInstance<Hospital>();
h.ShowId();
}
So I'm passing a Doctor object as the first constructor param to Hospital, and I'm trying to set the level
param to 23. When I run the above code I get:
Unhandled Exception: StructureMap.StructureMapException: StructureMap Exception Code: 205 Missing requested Instance property "level" for InstanceKey "5f8c4b74-a398-43f7- 91d5-cfefcdf120cf"
So it looks like I'm not setting the level
param at all. Can someone point me in the right direction - how do I set the level
param in the constructor?
Cheers. Jas.