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 8942067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:26:28+00:00 2026-06-15T11:26:28+00:00

We have been using Windsor Castle as our DI Container but we are looking

  • 0

We have been using Windsor Castle as our DI Container but we are looking around for alternatives. Now I got to the Simple Injector and so far I have been impressed by its simplicity but one scenario I am stuck at right now is when we are using late bound instantiation for some of our components.

My first question is, is it even possible?

With Windsor it is done like this;

Container.Register(Component.For<ILogger>()
    .UsingFactoryMethod(
        (kernel, componentModel, context) => new Logger(
            context.Handler.ComponentModel.Implementation.Name));

Is there a way to do the same with Simple Injector?

  • 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-06-15T11:26:30+00:00Added an answer on June 15, 2026 at 11:26 am

    With Simple Injector, you will just have to either:

    1. Register a Func delegate explicitly using Register<Func<A, B, C>>((a, b) => { ... })
    2. Create an interface such as ILoggerFactory, creste an implementation and register them.

    UPDATE

    After reading your question again and looking up the definition of Castle’s UsingFactoryMethod I came to the conclusion that I misinterpreted your question. What you are looking for is creating an instance based on its parent type: Context Based Injection.

    You can achieve this by implementing the Context Based Injection Extension method that is given as example on the Simple Injector’s documentation wiki.

    When you add this extension method to your project you can do the equivalent registration as follows:

    container.RegisterWithContext<ILogger>(context =>
    {
        return new Logger(context.ImplementationType.Name);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the Windsor IoC Container for my web-based application, to resolve
I have been looking into the Castle project and specifically Windsor. I have been
I have been using echo $.sprintf(%01\$.2f,$numvar); for my USD formatting, but I only copied
I'm fairly new to the DI concept, but I have been using it to
have been using no DOCTYPE but rather simply starting with <html> as per HTML5
Have been using a simple CSS only tooltip. Working Example css: .tip { position:relative;
I have been using Automapper in our projects and just recently ran into an
I've been using Castle Windsor in my previous project and I liked it a
I have what is probably a simple question here about Castle Windsor, which I
I have been using Javascript but more in a procedural way not the object

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.