Emiliano Sandler
Emiliano Sandler

Reputation: 44

ABP Feature Management - How to add a new scope?

I am developing an event management application with ASP.NET Boilerplate and Module Zero.

The features management included with ASP.NET Boilerplate allows to scope features to an Edition or to a Tenant.

I would like to know if it's possible to extend features to be scoped to events, so I can assign specific features of our application individually to each event our tenants create.

Is this possible? What is the best way to implement this with ABP?

Upvotes: 0

Views: 1603

Answers (1)

aaron
aaron

Reputation: 43098

I would like to know if it's possible to extend features to be scoped to events... Is this possible?

Sure. You can:

  • subclass Feature
  • subclass FeatureSetting
  • create a new FeatureScopes enum to include Events
  • implement and replace IFeatureChecker
  • implement and replace IFeatureManager
  • override methods in FeatureValueStore

That looks like a lot of work. But it is done like that for maintainability and separation of concerns.

What is the best way to implement this with ABP?

You're better off using Feature as-is, enabled for the tenant, and then replace FeatureChecker:

public async Task<string> GetValueAsync(int tenantId, string name)
{
    var feature = _featureManager.Get(name);

    var value = await FeatureValueStore.GetValueOrNullAsync(tenantId, feature);
    if (value == null)
    {
        return feature.DefaultValue;
    }

    // Check if Feature is enabled for Event
    // ...

    return value;
}

Upvotes: 2

Related Questions