Mar 13, 2008 at 6:32 PM
I'm not sure about the logic that maps a Type parameter into a ResolvedParameter.

We lose the possibility to pass Type arguments as "literal values" to our ctor, methods, ...

I'd rather prefer for it to be explicit ; it you want a ResolvedParameter, you instantiate one explicitly, no hidden magic as it doesn't bring much to the table.

You need to instantiate one explicitly anyways when you need to provide a name as part of the resolve key.
Mar 13, 2008 at 8:35 PM
You don't lose any capabilities, you just need to be more explicit.

If you want to register a literal Type object, you do:

new InjectionContructor(new InjectionParameter(typeof(Whatever)))

At least, that should work - I'll need to double check the code. It's supposed to work, anyway.

In my experimentation, I found that 80% of the time when I needed a type I was telling the container to resolve something rather than passing a Type instance. That's why the logic is the way it is - it worked out to be a useful default for me. I'm willing to be convinced to change it if others find it more usable the other way.
Mar 13, 2008 at 9:29 PM
Oh right, I didn't realize you didn't really lose the capability. At least, there's a workaround and I also think it would work

Then to me, it's more for consistency than anything else.

public class Foo
  public Foo(string name, Type barType, ILogger logger, IDataAccess dataAccess) { ... }
public class CrazyBar { ... }

What your're proposing:

new InjectionConstructor(
new InjectionParameter(typeof(CrazyBar)),
typeof(ILogger), //Use default
new ResolvedParameter<IDataAccess>("SQL") // Use specific

compared to:

new InjectionConstructor(
new ResolvedParameter<ILogger>(), //Use default
new ResolvedParameter<IDataAccess>("SQL") // Use specific
Mar 13, 2008 at 9:53 PM
Yep, that's it exactly.