Developer forum

Forum » Development » Custom features with the FeatureManager

Custom features with the FeatureManager

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I can see I can implement my own feature toggles by inheriting FeatureBase. I can see the feature show up in the backend, which is nice.

What is the best way to use it? I am looking for options in both backend code as well as Razor templates. Is that even supported? Is there a static FeatureManager or so? Code I found so far seems to use the DI container to resolve the manager:

var featureManager = DependencyResolver.Current.GetRequiredService<FeatureManager>();
if (featureManager.IsActive<MyNewFeature>()) { ... do something }

Is that the correct approach?

The docs bot suggests Feature<T>IsActive() but I can see it's marked as obsolete...

Imar
 

 

 


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Imar,

I would recommend using DI if possible to get the feature manager and do the check as you already do. Otherwise, you can use Feature.IsActive<T>().

- Jeppe

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Jeppe!

 

You must be logged in to post in the forum