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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:06:38+00:00 2026-06-12T00:06:38+00:00

I have an interface IRofl with an implementation called DefaultRofl with the following constructor

  • 0

I have an interface IRofl with an implementation called DefaultRofl with the following constructor signature:

public DefaultRofl(ICanHasCheezburger cheez)

ICanHasCheezburger has several implementations, of which I need to resolve more than one through the IoC container, and I thought named registrations were the correct way for this.

Let’s say I have two pre-created instances and want one to be the default registration, the other one named:

container.Register<ICanHasCheezburger>(cheez1);
container.Register<ICanHasCheezburger>(cheez2, "x2");

Now I need to specify that for DefaultRofl, the “x2” registration should be resolved – and this is where I’m stuck. I know Autofac can do this, but I can’t find a way with TinyIoC.

I would have expected the way to do this to be

container.Register<IRofl, DefaultRofl>().UsingConstructor(() => new DefaultRofl(container.Resolve<ICanHasCheezburger>("x2")));

but as it turns out (and I even sort of understand why), the ICanHasCheezburger constructor parameter is just a dummy and not actually evaluated. This means the name is ignored as well, and the default registration for the interface is resolved – but this is cheez1, which I don’t want to use here.

Actually, in one more case of Jeff Atwood’s rubber duck problem solving, I just kind of figured it out:

container.Register<IRofl>((c, p) => new DefaultRofl(container.Resolve<ICanHasCheezburger>("x2")));

does the trick. However, if I had more constructor arguments, I’d have to explicitly state all the container.Resolve() calls, right? Steven? 😉

  • 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-12T00:06:39+00:00Added an answer on June 12, 2026 at 12:06 am

    If you use named registrations then the only three ways to retrieve them are either using the Resolve overload you have there (that takes the name), using ResolveAll manually or to take a dependency of IEnumerable which will give you all the named registrations of Foo.

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

Sidebar

Related Questions

I have interface Foo public interface Foo { public void test(); } Class FooChild
I have two questions 1) my interface i have interface called IRegister and within
I have an interface: public interface: IA { ... } and I try to
I have an Interface like this: namespace QuickRoutes.Model.Utilities { public interface IRoutesManager { bool
I have next interface public interface IMyInterface { string this[string key] { get; set;
I have interface: public interface CartService extends RemoteService{ <T extends ActionResponse> T execute(Action<T> action);
I have interface IModule and several classes that implements it. In test i need
I have a Device interface: public interface IDevice { double Measure(); } Some classes
Is it possible in PHP 5 to have an interface that has private /
lets say I have an NSWindow Class, that has several events for mouse and

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.