3

I made a post on the Ninject forum but haven't received any answers... wondering if anyone has any suggestions?

http://groups.google.com/group/ninject/browse_thread/thread/9ac79d5541f015cb

Hello everyone, I have a few different workflows in a windows service and these workflows share some dependencies. I'd like to define multiple scopes, and then bind into that scope. If I make multiple bindings, each with the different scope, I get an exception that basically says I have duplicate bindings. Is there a preferred way of doing this?

Thanks!

schaibaa
  • 71
  • 2

1 Answers1

3

Scopes define the lifecycle and not when to use which binding. Use conditional bindings to tell when to use which type. E.g. Add a name to some parent binding and use WhenParentNamed or WhenAnyAnchestorNamed to tell which binding should be used.

In case the only reason for having multiple bindings is that you have different scope names then consider to use the same scope name instead. It is not required that they are different. E.g. If you have multiple controllers then they can all define the controller scope.

Remo Gloor
  • 32,665
  • 4
  • 68
  • 98