https://github.com/moattarwork/onff
Toggle switching library for .net core
https://github.com/moattarwork/onff
dotnet-core dotnet-standard
Last synced: about 1 month ago
JSON representation
Toggle switching library for .net core
- Host: GitHub
- URL: https://github.com/moattarwork/onff
- Owner: moattarwork
- License: gpl-3.0
- Created: 2019-02-13T21:45:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-11T23:16:52.000Z (almost 7 years ago)
- Last Synced: 2025-03-04T06:14:38.511Z (over 1 year ago)
- Topics: dotnet-core, dotnet-standard
- Language: C#
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Onff
Onff is a feature toggling library for .net standard.
[](https://ci.appveyor.com/project/moattarwork/onff)
[](https://www.nuget.org/packages/Onff/)
The package can be downloaded from NuGet using
```console
install-package Onff
Install-package Onff.Extensions
```
or
```console
dotnet add package Onff
dotnet add package Onff.Extensions
```
## Usage
The features can be configured in *appSettings.json* as:
```json
{
"Features": {
"Feature1": true,
"Feature2": false
}
}
```
The package consists of extensions to register relative services in ServiceCollection.
```csharp
services.AddFeatureToggling();
.
.
.
public class SampleService
{
private readonly IFeatureToggle _featureToggle;
public SampleService(IFeatureToggle featureToggle)
{
_featureToggle - featureToggle;
}
public virtual void Call()
{
if (_featureToggle.IsFeatureEnabled("FeatureName"))
{
// Do something related to the feature
}
// OR
if (Features.IsEnabled("FeatureName"))
{
// Do something related to the feature
}
}
}
```
Also every section of the code can be run due to status of a feature
By using **Features** static class
```csharp
public static TResult Run(Func func, string featureName);
public static void Run(Action action, string featureName);
public static Task RunAsync(Func> func, string featureName);
public static Task RunAsync(Func action, string featureName);
```
Or by using **IFeatureToggle** class
```csharp
public TResult Run(Func func, string featureName);
public void Run(Action action, string featureName);
public Task RunAsync(Func> func, string featureName);
public Task RunAsync(Func action, string featureName);
```