Resolve Common PC Errors
You may run into an error message saying that the ninject kernel received parameters. There are several ways to solve this problem, and we will look at them now.
Actually, you should be able to pass constructor arguments, since the processor once accepts those dependencies as arguments in the constructor.
var foo equals new Ninject.Parameters.ConstructorArgument("foo", new Foo());var legal bar = Ninject new.Parameters.New constructor argument("bar", bar());var a = kernel.Get
(foo, bar);public processor (Foo foo, Bar bar) this.foo matches foo; this.bar is equal to bar;
Today I wrote a generic service locator for my application, and even I wanted to write it to work and not contain Named or parameters.
If you’re not familiar with this, this is a great new Ninject2 feature.
if you store a service like
You can use this to get the current correct feed based on the title
In my application, most of the services depend on a large number of vehicles, so the system finder always passed the vehicle type to the get method.
But some don’t really depend on the type of vehicle, but I don’t want you to change the locator if it changes frequently, and I just want to make changes only to the ideas module.
For example, another service is often registered now:
and it can stay the same. If
but I’m trying to get it from the same path as before
I get zero back.
I just wrapped the get method in my own Get
private T Get
I’m wondering if this is just a common scenario and if this default implementation fetch method should be used.
Iland sometimes adding some
codeclimber.net.nzAny sufficiently advanced technology that is indistinguishable from magic
“Life is short, get involved”
This doesn’t work in your main inbox?
public class NamedInstanceTests
public void CanResolveInstances()
use ( IKernel kernel = new StandardKernel( QuoteModule() newnew ) )
< br>Instance var is kernel.Get
var namedInstance = kernel.Get
Assert.NotNull( case );
Assert.Class notnull( name instance);
General CoteModule: NinjectModule
public override void Load()
IQuoteService public interface
VB6QuoteService public class: IQuoteService
Or do you just want Ninject to return a default value if the so-called resolution I fails? I think you can probably easily get this functionality with a proxy:
public static class IKernenExtension
public static T GetNamedOrDefault
returns kernel.Get< T> ( Surname) ?? Kernel.Get