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
namestringThe unique feature name (cannot be null or empty).
categorystringThe category/group for the feature (cannot be null or empty).
Exceptions
- ArgumentNullException
Thrown when
nameorcategoryis 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
namestringThe unique feature name.
categorystringThe category/group for the feature.
defaultValueboolThe 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
namestringThe unique feature name.
categorystringThe category/group for the feature.
defaultValueboolThe default activation state.
descriptionstringA human-readable description.
documentationLinkstringA 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
DefaultValue
Gets the default activation state for the feature if no explicit override is stored.
public bool DefaultValue { get; }
Property Value
Description
Gets an optional human-readable description of what the feature does.
public string? Description { get; init; }
Property Value
DocumentationLink
Gets an optional link to external documentation describing the feature in more detail.
public string? DocumentationLink { get; init; }
Property Value
Name
Gets the unique name of the feature flag. This is the identifier shown in the UI.
public string Name { get; }
Property Value
Methods
IsActive<T>()
Determines whether a feature of type T is currently active.
public static bool IsActive<T>() where T : Feature, new()
Returns
- bool
trueif the feature is active; otherwisefalse.
Type Parameters
TThe concrete Feature type.
Remarks
Uses DI to resolve FeatureManager.
- See Also