Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:19:02+00:00 2026-05-29T09:19:02+00:00

In the past, I used swiftsuspenders that is an actionscript 3 IoC controller. Basically

  • 0

In the past, I used swiftsuspenders that is an actionscript 3 IoC controller. Basically the first version of switfsuspender had something similar to the Ninject kernel that was called injector.

If I wanted to create an application injector (with let’s say the most relevant mappings to be used throughout the application), I had to inject the injector itself in the application classes.

I am wondering now what is the practice to use kernel.get<> among several classes in the application. Should I inject the kernel itself?

Personally I’d rather use kernel.inject but if I can do kernel.inject I can really likely inject the dependencies manually, which is probably better (kiss).

Test cases are nice, but they are far from the real practical issues, so I hope you can help me to clarify this point. Thank you.

Edit: I noticed that some people talk about “root container”, It seems like it is the concept I am looking for. How should I setup a root container and let the other application classes know it?

Edit2 Sample code (please forgive errors, it is just for example sake):

class SomeClass
{
    public SomeClass()
    {
        Command cmd = new Command();

        cmd.execute();
    }

}

class SomeOtherClass:ISomeOtherClass
{
 public void allright()
 {
    //right
 }
}

class Command
{
   ISomeOtherClass dependency;

   void execute()
   {
    dependency.allright();
   }

}


Program.Main()
{
    IKernel kernel = new StandardKernel();

    kernel.Bind<SomeClass>().ToSelf().InSingletonScope();
    kernel.Bind<ISomeOtherClass>().To<SomeOtherClass>();

    SomeClass sc = kernel.Get<SomeClass>();
}

I did not test this yet, because I am still fighting with some initialization issues, but my question is, how can the command class know about SomeOtherClass? My current hypothesis is to inject the kernel in SomeClass and use the method Inject.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:19:03+00:00Added an answer on May 29, 2026 at 9:19 am

    Looking at your example, it is clear that SomeClass is not built with Inversion of Control in mind; the tip-off being that it has a dependency on Command, but control of that dependency is maintained inside SomeClass itself. (Command cmd = new Command();)

    To invert the control of that dependency, you would need to have a way to inject that dependency into SomeClass. As Remo Gloor has indicated, the standard way of doing that with Ninject is through the constructor.

    To do so, you might change SomeClass to something like this:

    class SomeClass
    {
        private ICommand _command;
    
        public SomeClass(ICommand injectedCommand)
        {
            _command = injectedCommand;
            _command.execute();
        }
    
    }
    

    Likewise you would need your Command to advertise its dependency:

    class Command
    {
       private ISomeOtherClass _dependency;
    
       public Command(ISomeOtherClass injectedSomeOtherClass)
       {
            _dependency = injectedSomeOtherClass;
       {
    
       void execute()
       {
          _dependency.allright();
       }
    }
    

    Then you would register your Command binding in the kernel, perhaps like:

    Program.Main()
    {
        IKernel kernel = new StandardKernel();
    
        kernel.Bind<SomeClass>().ToSelf().InSingletonScope();
        kernel.Bind<ICommand>().To<Command>();
        kernel.Bind<ISomeOtherClass>().To<SomeOtherClass>();
    
        SomeClass sc = kernel.Get<SomeClass>();
    }
    

    The kernel would then be able to walk the dependency chain and inject them all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did write some apps in the past that used access en sqlserver databases.
In the past ive used xpath to find the value of specific nodes that
I had used SosAssistin past and it was awesome, now I i tried to
In the past I've used profman2 to create MAPI profiles for servers that need
In the past people used to wrap HTML comment tags around blocks of JavaScript
In the past I used to configure .NET code groups with the Mscorcfg.msc utility.
Several of my ajax applications in the past have used GET request but now
In the past I've used RailsForum.com as a resource, but lately I've come across
In the past I have used MAPISendMail to launch Outlook (or whatever the desired
In the past I have used Managed Direct X and DirectShow.Net to play a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.