Issue With Ninject Kernel Get Options

Resolve Common PC Errors

  • 1. Go to the ASR Pro website and click on the "Download" button
  • 2. Follow the on-screen instructions to install ASR Pro
  • 3. Open ASR Pro and click on the "Scan now" button
  • Improve your computer's speed and performance with this free software download.

    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;

    Simona Chiaretta

    unread,

    Mar 17, 2009 4:02:09 PM 20.09.09

    for nin…@googlegroups.com

    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

    Bind().To().Named(“car”);

    Bind().To().Named(“boat”);

    You can use this to get the current correct feed based on the title

    _kernel.Get(“car”);

    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.

    p>

    For example, another service is often registered now:

    Bind() as.To();

    and it can stay the same. If

    ninject kernel get parameters

    but I’m trying to get it from the same path as before

    _kernel.Get(“auto”)

    I get zero back.

    I just wrapped the get method in my own Get

    method

    private T Get (string tipoBene) where Class

    with:

    return _kernel.Get(tipoBene)?? _core.

    But 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

    Reference ().To().Named().Always() to make it clearer

    Simon

    Simone Chiaretta

    codeclimber.net.nzAny sufficiently advanced technology that is indistinguishable from magic

    “Life is short, get involved”

    Ian Davis

    unread,

    Over Mar 20, 2009 4:28:24 3/20/09

    Resolve Common PC Errors

    Is your computer acting up? Don't worry, ASR Pro is here to help. With just a few clicks, our software can scan your system for problems and fix them automatically. So you can get back to work as quickly as possible. Don't let a little glitch hold you back - download ASR Pro today!

  • 1. Go to the ASR Pro website and click on the "Download" button
  • 2. Follow the on-screen instructions to install ASR Pro
  • 3. Open ASR Pro and click on the "Scan now" button

  • for nin…@googlegroups.com

    This doesn’t work in your main inbox?

    public class NamedInstanceTests

    [Fact]
    public void CanResolveInstances()

    use ( IKernel kernel = new StandardKernel( QuoteModule() new[]new ) )
    < br>Instance var is kernel.Get();
    var namedInstance = kernel.Get(“car”);
    Assert.NotNull( case );
    Assert.Class notnull( name instance);

    ninject kernel get parameters

    General CoteModule: NinjectModule

    public override void Load()

    Bind().To().Named(“car”);

    Bind ( ).To();

    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(this is IKernel core, string name) where T: class

    returns kernel.Get< T> ( Surname) ?? Kernel.Get();

    -Yan

    Ian Davis