Table of Contents

Class Feature

Namespace
Dynamicweb.Core
Assembly
Dynamicweb.Core.dll

Base type for defining a feature flag in the system. Inheriting this makes the feature flag visible in the backend through Settings > Administration > Feature Management.

public abstract class Feature
Inheritance
Feature
Derived
Inherited Members

Remarks

A concrete feature should expose a public parameterless constructor so it can be instantiated by the feature system (e.g. when scanning types). Prefer interacting with features through FeatureManager injected via DI rather than the obsolete instance methods.

Constructors

Feature(string, string)

Initializes a new instance of the Feature class with a name and category.

protected Feature(string name, string category)

Parameters

name string

The unique feature name (cannot be null or empty).

category string

The category/group for the feature (cannot be null or empty).

Exceptions

ArgumentNullException

Thrown when name or category is null or empty.

Feature(string, string, bool)

Initializes a new instance of the Feature class with a name, category and default state.

protected Feature(string name, string category, bool defaultValue)

Parameters

name string

The unique feature name.

category string

The category/group for the feature.

defaultValue bool

The default activation state.

Feature(string, string, bool, string, string)

Initializes a new instance of the Feature class including metadata.

protected Feature(string name, string category, bool defaultValue, string description, string documentationLink)

Parameters

name string

The unique feature name.

category string

The category/group for the feature.

defaultValue bool

The default activation state.

description string

A human-readable description.

documentationLink string

A link to external documentation.

Properties

Category

Gets the category/group the feature belongs to. Used for logical grouping in the UI.

public string Category { get; }

Property Value

string

DefaultValue

Gets the default activation state for the feature if no explicit override is stored.

public bool DefaultValue { get; }

Property Value

bool

Description

Gets an optional human-readable description of what the feature does.

public string? Description { get; init; }

Property Value

string

Gets an optional link to external documentation describing the feature in more detail.

public string? DocumentationLink { get; init; }

Property Value

string

Name

Gets the unique name of the feature flag. This is the identifier shown in the UI.

public string Name { get; }

Property Value

string

Methods

IsActive<T>()

Determines whether a feature of type T is currently active.

public static bool IsActive<T>() where T : Feature, new()

Returns

bool

true if the feature is active; otherwise false.

Type Parameters

T

The concrete Feature type.

Remarks

Uses DI to resolve FeatureManager.

See Also

See Also

To top