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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:11:45+00:00 2026-06-12T21:11:45+00:00

I have an interface INavigationService and a simple container that allows registration with and

  • 0

I have an interface INavigationService and a simple container that allows registration with and without key.

This is useful to me as the framework will inject the registered instances into the constructor of my view models.

Now I have multiple navigation services (due to frames in my UI). They all implement the same basic interface (INavigationService).

I want to be able to have the container inject these instances into the correct navigation tree (frame + subsequent views/view models) without me having to pass around parameters (DI registration key).

How is this usually done?

I can imagine something that is attribute based (thus putting the registration key onto all dependent class definitions). But the container doesn’t support this. It also seems to be a hassle.

I could also create an interface exclusively for tagging. So INavigationService<T> and register each navigation service with a different type argument. E.g. the type of the first view of a frame. This would give me the resolution I need, although I would pass around interfaces that do not have any meaning.

On the other hand, I get IDE support for finding dependent views (for example by creating types like FileTreeNavigation : INavigationService<FileTreeView>

Is there another pattern?

  • 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-12T21:11:47+00:00Added an answer on June 12, 2026 at 9:11 pm

    I’m not sure how this applies to Caliburn Micro, but since the question is about patterns, I’ll describe here the way I managed to solve this problem with StrucureMap: using the Ctor<> method which allows specifying concrete types for constructor parameter resolution.

    Also, I think using specialized interfaces (your FileTreeNavigation example) is great, but if for some reason you don’t find this appropriate, read on.

    Let’s suppose that we have the INavigationService interface and two different implementations:

    public interface INavigationService { }
    public class NavigationServiceA : INavigationService { }
    public class NavigationServiceB : INavigationService { }
    

    Next, we have two different Service classes, both depending on the INavigationService interface:

    public class ServiceA
    {
        private readonly INavigationService _navigationService;
    
        public ServiceA(INavigationService navigationService)
        {
            _navigationService = navigationService;
        }
    }
    
    public class ServiceB
    {
        private readonly INavigationService _navigationService;
    
        public ServiceB(INavigationService navigationService)
        {
            _navigationService = navigationService;
        }
    }
    

    Finally, we have a class that we’ll resolve using the IoC container. The class depends on both ServiceA and ServiceB and is defined as follows:

    public class SomeClassToResolve
    {
        private readonly ServiceA _serviceA;
        private readonly ServiceB _serviceB;
    
        public SomeClassToResolve(ServiceA serviceA, ServiceB serviceB)
        {
            _serviceA = serviceA;
            _serviceB = serviceB;
        }
    }
    

    StructureMap offers the possibility of specifying what type to use in order to resolve a constructor parameter. This is how the registration looks like:

    ForConcreteType<ServiceA>().Configure.Ctor<INavigationService>().Is<NavigationServiceA>();
    ForConcreteType<ServiceB>().Configure.Ctor<INavigationService>().Is<NavigationServiceB>();
    

    Now, when I call container.GetInstance<SomeClassToResolve>(); it’ll construct an instance of SomeClassToResolve, which has instances of ServiceA and ServiceB correctly constructed (having NavigationServiceA and NavigationServiceB, respectively).

    This is one way to do it, that I found to be more straight forward. There’s also the possibility of doing Conditional Construction, but I think that can get pretty complex.

    PS: searching for “caliburn micro constructor” I stumbled upon this approach which seems similar to what I’m doing with StructureMap (only that here it’s called InjectionConstructor).

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

Sidebar

Related Questions

I have next interface public interface IMyInterface { string this[string key] { get; set;
Let's say we have interface window_creator that responsible for creation of windows. For simplicity
I'm trying to figure out why this code won't compile. I have interface A
I have an Interface like this: namespace QuickRoutes.Model.Utilities { public interface IRoutesManager { bool
I have: @interface SuperClass : UIViewController <UITableViewDelegate,UITableViewDataSource> And then @interface SubClass : SuperClass This
I have interface IModule and several classes that implements it. In test i need
I have custom control and I have interface this control exposes to it's users.
I have custom control and I have interface this control exposes to it's users.
Is it possible in PHP 5 to have an interface that has private /
i have interface: public interface Inx<T> { T Set(Data data); } simple class with

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.