Abp settings features

From burakdmir/abp-skills · View interactive version

Abp settings features is an AI agent skill from the GitHub repository burakdmir/abp-skills. ABP Framework v10.x (10.4–10.6) settings and features: ISettingProvider/ISettingManager, SettingDefinitionProvider, IFeatureChecker, feature toggle. Use for configuration management, settings, or feature flags in ABP.

How to use this skill

Skill file

ABP Settings & Features Skill

Trigger

Settings, ISettingProvider, ISettingManager, setting values, features, IFeatureChecker, feature toggles, feature management.


Settings

Define

public class BookStoreSettingDefinitionProvider : SettingDefinitionProvider
{
    public override void Define(ISettingDefinitionContext context)
    {
        context.Add(
            new SettingDefinition("App.UI.LayoutType", defaultValue: "LeftMenu",
                displayName: L["LayoutType"], isVisibleToClients: true),
            new SettingDefinition("Smtp.Password", defaultValue: "", isEncrypted: true)
        );
    }
}

Read (ISettingProvider — cached, read-only)

string v = await _provider.GetOrNullAsync("Smtp.UserName");
bool ssl = await _provider.GetAsync<bool>("Smtp.EnableSsl");
bool ssl = await _provider.IsTrueAsync("Smtp.EnableSsl");
int port = await _provider.GetAsync<int>("Smtp.Port");
int? port = (await _provider.GetOrNullAsync("Smtp.Port"))?.To<int>();

ApplicationService has SettingProvider property pre-injected.

Write (ISettingManager — for UIs)

await _mgr.SetForCurrentTenantAsync("App.UI.LayoutType", "LeftMenu");
await _mgr.SetForUserAsync(userId, "App.UI.LayoutType", "LeftMenu");
await _mgr.SetGlobalAsync("App.UI.LayoutType", "TopMenu");
string v = await _mgr.GetOrNullGlobalAsync("App.UI.LayoutType");

Fallback Chain (bottom → top)

D (Default) → C (Configuration) → G (Global) → T (Tenant) → U (User)

appsettings.json

{ "Settings": { "Smtp.EnableSsl": "true" } }

Custom Value Provider

public class CustomProvider : SettingValueProvider
{
    public override string Name => "Custom";
    public override Task<string> GetOrNullAsync(SettingDefinition s) { ... }
}
Configure<AbpSettingOptions>(o => o.ValueProviders.Add<CustomProvider>());

Features

Define

public class FeatureDefProvider : FeatureDefinitionProvider
{
    public override void Define(IFeatureDefinitionContext ctx)
    {
        var g = ctx.AddGroup("BookStore");
        g.AddFeature("BookStore.PdfReporting", defaultValue: "false",
            displayName: L["PdfReporting"], valueType: new ToggleStringValueType());
        g.AddFeature("BookStore.MaxProductCount", defaultValue: "10",
            valueType: new FreeTextStringValueType(new NumericValueValidator(0, 1000000)));
    }
}

Value Types

Check

[RequiresFeature("BookStore.PdfReporting")]  // Attribute
if (await FeatureChecker.IsEnabledAsync("BookStore.PdfReporting")) { }  // Service
string v = await FeatureChecker.GetOrNullAsync("BookStore.MaxProductCount");

Child Features

var parent = g.AddFeature("BookStore.Reporting", valueType: new ToggleStringValueType());
parent.AddChild("BookStore.PdfExport", valueType: new ToggleStringValueType());

Settings vs Features

| | Settings | Features |

|---|---|---|

| Purpose | Config values | Functionality toggles |

| Scope | User/Tenant/Global | Tenant only |

| Fallback | 5-level chain | Default only |

| Encryption | Yes | No |

Best Practices

Related

Authorization · Multi-Tenancy · Infrastructure · Docs: https://abp.io/docs/latest/framework/infrastructure/settings

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.