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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:29:23+00:00 2026-06-17T03:29:23+00:00

I have some feature toggles that I include in my .NET application which uses

  • 0

I have some feature toggles that I include in my .NET application which uses StructureMap. I want to register the feature toggles for two purposes.

  • Display current state of all IFeatures on a diagnostic page.
  • Use certain instances in constructors of services that rely on given IFeature implementations

Here is my setup. What I’m wondering is, am I doing this right? Is there a better way I could be doing it?

class HotNewFeature : IFeature { ... }

class ServiceThatUsesFeature 
{
    public ServiceThatUsesFeature(HotNewFeature hotNewFeature) { ... }
}

// Type registry setup
For<HotNewFeature>().Singleton().Use<HotNewFeature>();
For<IFeature>().Singleton().Add(c => c.GetInstance<HotNewFeature>);
For<ServiceThatUsesFeature>().Singleton().Use<ServiceThatUsesFeature>());

// Get all instances on the diagnostics page:
IEnumerable<IFeature> features = ServiceLocator.Current.GetAllInstances<IFeature>();

I expect that on the diagnostic page, features would in this case contain an IEnumerable with a single element, the instance of HotNewFeature.

  • 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-17T03:29:24+00:00Added an answer on June 17, 2026 at 3:29 am

    Use the Scan feature to register all types that implement IFeature. That will satisfy your first need, to display a list on the Diagnostics page.

    If a service needs a specific implementation, it should declare the specific type it needs (HotNewFeature) instead of the interface (IFeature) in the constructor. You have done this correctly in your example. At that point you do not need to do anything more in StructureMap. If you request ServiceThatUsersFeature from StructureMap, and it relies on a concrete class (HotNewFeature), StructureMap will know how to instantiate that concrete class.

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

Sidebar

Related Questions

I have a rails application in which I implemented some feature. Now I want
I have some models witch are using Doctrine nestedset feature. I want to add
Here's a problem. Developers have some kind of a task (develop certain feature), which
I have a site that features some pages which do not require any post-back
I have some arbitrary pixel data that I want to save as a PNG.
We have some legacy stored procedures that use the now deprecated feature of SQL
In master I have some files that should better live in a feature branch.
currently i have a project using solr,now i want to add some feature,so i'm
We have some feature branches that can get put on ice for a few
I have some css files that are deployed in a feature scoped to site

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.