[Dependency(CreateType = typeof (Foo))]

Jun 11, 2008 at 4:46 PM
Edited Jun 11, 2008 at 4:53 PM
I often used the CreateType parameter in ObjectBuilder with CAB, and this is not available in Unity.
Have I been lulled into bad practice - is this removed for best practices reasons? Or is it just a lower priority feature?

[Dependency(CreateType = typeof (Foo))]
public IFoo Foo
{ set { _foo = value; } }
Jun 20, 2008 at 2:57 AM
I think what you would do in Unity is to call

container.RegisterType<IFoo, Foo>();
Then you could just take IFoo as a constructor argument.


PandaWood wrote:
I often used the CreateType parameter in ObjectBuilder with CAB, and this is not available in Unity.
Have I been lulled into bad practice - is this removed for best practices reasons? Or is it just a lower priority feature?

[Dependency(CreateType = typeof (Foo))]
public IFoo Foo
{ set { _foo = value; } }



Jun 20, 2008 at 5:28 AM
We didn't do any kind of survey of features of CAB, or OB1 for that matter, when building Unity.

That being said, I personally feel that kind of configuration belongs in the container, not on the class being created. As such, I doubt we'll be implementing it in the core codebase. It wouldn't be too hard to do as an extension, though.