Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
askpt committed Apr 30, 2024
1 parent 31ba188 commit 533aea8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dotnet add package OpenFeature
public async Task Example()
{
// Register your feature flag provider
await Api.Instance.SetProvider(new InMemoryProvider());
Api.Instance.SetProvider(new InMemoryProvider());

// Create a new client
FeatureClient client = Api.Instance.GetClient();
Expand All @@ -67,6 +67,29 @@ public async Task Example()
}
```

### DI Usage

```csharp
// Register your feature flag provider
builder.Services.AddOpenFeature(static builder =>
{
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<FeatureProvider, SomeFeatureProvider>());
builder.TryAddOpenFeatureClient(SomeFeatureProvider.Name);
});

// Inject the client
app.MapGet("/flag", async ([FromServices]IFeatureClient client) =>
{
// Evaluate your feature flag
var flag = await client.GetBooleanValue("some_flag", true).ConfigureAwait(true);

if (flag)
{
// Do some work
}
})
```

## 🌟 Features

| Status | Features | Description |
Expand Down

0 comments on commit 533aea8

Please sign in to comment.