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

  • SEARCH
  • Home
  • 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 6844189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:20:43+00:00 2026-05-27T00:20:43+00:00

I’m a beginner on IoC and dependency injection. I’m reading about it, but I

  • 0

I’m a beginner on IoC and dependency injection. I’m reading about it, but I just can’t get it.
While I figure out how stuff works, I’m trying to implement some of these patterns on my project (and maybe learn by trial and error).

I’m implementing security control by using FluentSecurity package (from NuGet, btw). I need to implement a Policy Violation Handler, as described on this wiki. The problem is that the example is written for StructureMap IoC-container, and I’m using (or trying to) Ninject 2.2 (it seemed more simple for a beginner).

On their code, they suggest (a):

configuration.ResolveServicesUsing(type => ObjectFactory.GetAllInstances(type).Cast<object>());

And then (b):

public class WebRegistry : Registry
{
    public WebRegistry()
    {
        Scan(scan =>
        {
            scan.TheCallingAssembly();
            scan.AddAllTypesOf<IPolicyViolationHandler>();
        });
    }
}

My concerns:

  1. I know that code (a) will be included on Global.asax. But what is Ninject’s alternative to ObjectFactory.GetAllInstances()?
  2. I have no idea neither where this code should be inserted nor what are the equivalents for WebRegistry, Scan, and the internal functions TheCallingAssembly and AddAllTypesOf.

I know this is a bit extensive question, but I appreciate any help! Thanks in advance.

  • 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-27T00:20:44+00:00Added an answer on May 27, 2026 at 12:20 am

    I think this would be roughly equivelent

    //add an instance of IKernel to your MvcApplication
    [Inject]
    public IKernel Kernel { get; set; }
    ...
    configuration.ResolveServicesUsing(type => Kernel.GetAll(type));
    

    To get the ability to scan an assembly for dependencies you would need an extension for ninject called Ninject.Extensions.Conventions, which was modeled after the one from SM.

    public class WebModule : NinjectModule
    {
        public WebModule()
        {
            Kernel.Scan(a => {
                        a.FromAssemblyContaining<YourType>();
                        a.BindWithDefaultConventions();
                        a.InTransientScope();
                    });
        }
    }
    

    The assembly scanning business obviously isn’t strictly necassary for what you’re doing, this would work just as well. Personally I’m not a fan of assembly scanning because it seems a little too “magic”, and when it doesn’t work, it’s not fun to debug.

    Kernel.Bind<YourType>().ToSelf();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.