Questions tagged [ninject-conventions]

Ninject Conventions is a Ninject Extension that helps to reduce binding configuration code by implementing configuration by convention.

Ninject Conventions is a Ninject Extension that helps to reduce the amount of binding configuration lines of code necessary when binding dependencies.

It provides a fluent means of implementing configuration by convention by allowing you to identify groups of components that require identical binding configuration, and specify the configuration in a single statement.

22 questions
8
votes
1 answer

Convention based binding of constructor string arguments with Ninject

I'm using Ninject as IoC container in my project. I have following class: public class SomeRepository:ISomeRepository { public SomeRepository(string someDatabaseConnectionString) { // some code here.. } } In my application…
5
votes
2 answers

Ninject dynamically bind to implementation

There are several questions on Stack Overflow that are similar but not exactly what I'm looking for. I would like to do Ninject binding based on a runtime condition, that isn't pre-known on startup. The other questions on Stack Overflow for dynamic…
DiskJunky
  • 4,750
  • 3
  • 37
  • 66
4
votes
2 answers

How do I bind generic types with inheritance using Ninject Conventions extensions

How can I bind InitializerForXXX (non-generic implementation) to IInitializer (generic interface) using Ninject Conventions so that requests for an IInitializer resolve a non-generic implementation whose name starts with InitializerFor and…
3
votes
1 answer

Ninject Conventions and Interception

I want to decorate my services with attributes for interception, and then have conventions based binding set the interceptors up for me. I don't want my attributes to inherit from the interception attributes... if I can avoid it. For example, I…
BlakeH
  • 3,354
  • 2
  • 21
  • 31
1
vote
1 answer

What Ninject convention should I use to bind all interfaces starting with "I" with interfaces having the same name without the "I" prefix for COMObj?

I'm working on integrating an accounting system which objects are COM objects. When binding one to one as follows, it works just fine. IKernel kernel = new StandardKernel(); kernel.Bind().ToMethod(_ => { return new AcoSDKX();…
Will Marcouiller
  • 23,773
  • 22
  • 96
  • 162
1
vote
1 answer

Ninject: More than one matching bindings are available same class twice

Given this class: public class UserQueryHandler : IQueryHandler, IQueryHandlerAsync { //..implementation } public interface IQueryHandler
1
vote
2 answers

Tell if Ninject convention bind failed

I am using Ninject.Extensions.Conventions to add bindings dynamically. The .dll names to load are stored in configuration. If the configuration is incorrect and the .dll can not be loaded it would be good to know about that. Currently any failure to…
Eric Scherrer
  • 3,328
  • 1
  • 19
  • 34
1
vote
1 answer

Avoiding multiple bindings with Ninject Extensions inheritance

I have classes that create a hierarchy such as this: public interface IHandler { } public class BaseHandler : IHandler { } public class DerivedHandler : BaseHandler { } Basically, the idea is that the functionality can be stacked…
Simon Whitehead
  • 63,300
  • 9
  • 114
  • 138
1
vote
1 answer

Ninject Conventions with Ninject Factory Extension To Bind Multiple Types To One Interface

I'm trying to expand on the scenario asked in the SO question titled Ninject Factory Extension Bind Multiple Concrete Types To One Interface by using Ninject Conventions for convention-based binding of the ICar implementations. I'm working off the…
1
vote
1 answer

Using Ninject custom instance providers to bind successfully using factory method argument to resolve

I've been studying this accepted answer to a similar question in which what I believe is a concrete factory returns an implementation based on a string argument on the factory method matching a named binding on the concrete implementation. I'm…
1
vote
2 answers

Do Ninject MetaData constrained Get()'s apply to child resolutions?

I am using ninject.extensions.conventions to bind all implementations in a given assembly and tag them with the assembly name as the binding's metadata. I can pull these items back out using a Get and supplying a func as standard. What I would like…
deanvmc
  • 5,957
  • 6
  • 38
  • 68
1
vote
1 answer

Handling application settings with ninject and convention based binding

I am using Ninject in an MVC3 application and am trying to switch over to conventions based binding with ninject.extensions.conventions. Now let's say I have a class that needs access to application settings such as: public class Foo : IFoo { …
0
votes
1 answer

Ninject just won't register MediatR.IRequestHandler<,> using convention-based binding?

As per following example: MediatR.Examples.Ninject I've a MediatorModule class as follows: public class MediatorModule : NinjectModule { public class ContravariantBindingResolver : NinjectComponent, IBindingResolver { public…
Will Marcouiller
  • 23,773
  • 22
  • 96
  • 162
0
votes
1 answer

Ninject to return implementation based on enumerator

It's entirely possible my approach is incorrect but I'd like to outline the actual requirements first before my attempt at a resolution. My approach is based on the details provided here Task: in a wizard oriented stucture, get a…
DiskJunky
  • 4,750
  • 3
  • 37
  • 66
0
votes
2 answers

How to use convention extension with complex initiation ( like: ToMethod )

example of convention extension kernel.Bind(x => { x.FromThisAssembly() .SelectAllClasses() .WithAttribute() .BindBase(); }); And each type which I get should be provide complex initiation with this method public…
1
2