TypeMapping and Lifetime stages

Feb 28, 2008 at 2:11 AM
I was wondering which should come first. Right now it is TypeMapping but I think it could be Lifetime.

One scenario that helps answer this question is: Should Lifetime be dependent upon the interface or the concrete type and I think it would be more natural if it was upon the interface:

As it is now:
container
  .Register<ILogger, DatabaseLogger>()
  .SetSingleton<DatabaseLogger>();

What it would be if we switched stages:

container
  .Register<ILogger, DatabaseLogger>()
  .SetSingleton<ILogger>();

I understand some will argue that being a singleton is a lot more a matter of implementation than anything else.

Any thoughts?

Do you see pros/cons if stages were to be switched?
Feb 28, 2008 at 4:19 AM
Personally, I like the stages in the current order. The reason is that the details of lifetime, like singleton, are things I think of as implementation details. And as such, multiple implementations of interfaces may prefer/be built for different lifetimes.