toggly
  • What is toggly?
  • 🚀Getting started
    • Creating your first project
    • Using our Feature Flag Demo
    • Inviting Your Team
    • API Documentation
  • 🔘Feature Flags
    • Feature Flags in C# / .NET
      • Views
      • Controllers & Actions
      • Dependency Injection
      • Routing
      • IFeatureManagerSnapshot
      • Persistent Flags Across Requests
      • Disabled Action Handling
      • State Change Handlers
      • Custom Context
      • Snapshot Providers
        • RavenDB
        • Entity Framework
      • Debugging Endpoint
      • Serving Front-end Flags
      • Undefined Features In Development
      • Deployments and Version
    • Feature Flags in Vue.js
      • Feature Component
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in JavaScript
      • Directly Checking a Flag
      • Definition Refresh
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in Flutter
      • Feature Widget
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in HTML/CSS
  • 📈Metrics
    • Metrics in C# / .NET
      • Feature Usage
      • Business Metrics
      • Performance Metrics
  • 👩‍💻Use Cases
    • For Engineers
      • Develop continuously, turn on when ready
    • For Product Managers
      • Measure Feature Impact
    • For Agile Teams
      • Faster QA Cycles
      • Streamline Your Releases
Powered by GitBook
On this page
  • AddTransient / AddScoped
  • Decorate

Was this helpful?

  1. Feature Flags
  2. Feature Flags in C# / .NET

Dependency Injection

Services can be conditionally injected, or conditionally decorate existing services.

AddTransient / AddScoped

services.AddTransientForFeature<ILinkService, GlobalLinkService>("GlobalLink");

Decorate

The decorator pattern injects the existing implementation of a service into the constructor of the decorator service

services.AddScoped<ITaxService, LocalTaxService>();
services.DecorateForFeature<ITaxService, AvalaraTaxService>("Avalara");

Transient, scoped and middleware flags take effect immediately and don't require an application restart. They are usually preferred for this reason over singleton implementations, which live for the entire lifetime of the application.

PreviousControllers & ActionsNextRouting

Last updated 2 years ago

Was this helpful?

🔘