5

Can someone please explain the difference between

container.Register(AllTypes.FromAssemblyContaining(typeof(BigCompanyRepository))
 .WithService.DefaultInterface()

and

container.Register(AllTypes.FromAssemblyContaining(typeof(BigCompanyRepository))
 .WithService.AllInterfaces()

What is meant by a "default interface"?

jenson-button-event
  • 18,101
  • 11
  • 89
  • 155

1 Answers1

6

It's a heuristic that looks for an implementation of an interface by removing the leading I:

  • IFoo -> Foo
  • IBar -> Bar
  • IKitchenSink -> KitchenSink

However, in my opinion, using this feature smells of an over-abundance of 1:1 interfaces.

Habeeb
  • 1,020
  • 16
  • 35
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • 1
    ok, but isn't the whole point of the 1:1 the DI of components/services that only have one (pluggable) implementation for this application instance (whether it be a test fixture or a web app) - the point being: pluggability? – jenson-button-event Nov 18 '11 at 17:02
  • 9
    Actually it can also match things like: `IFoo`--> `MarksSuperFoo` Basically it looks if, after you remove the leading `I` the class name __contains__ the interface name – Krzysztof Kozmic Nov 18 '11 at 23:43