@@ -70,21 +70,21 @@ dotnet add package OpenFeature
70
70
71
71
``` csharp
72
72
public async Task Example ()
73
- {
74
- // Register your feature flag provider
75
- await Api .Instance .SetProvider (new InMemoryProvider ());
73
+ {
74
+ // Register your feature flag provider
75
+ await Api .Instance .SetProvider (new InMemoryProvider ());
76
76
77
- // Create a new client
78
- FeatureClient client = Api .Instance .GetClient ();
77
+ // Create a new client
78
+ FeatureClient client = Api .Instance .GetClient ();
79
79
80
- // Evaluate your feature flag
81
- bool v2Enabled = await client .GetBooleanValue (" v2_enabled" , false );
80
+ // Evaluate your feature flag
81
+ bool v2Enabled = await client .GetBooleanValue (" v2_enabled" , false );
82
82
83
- if ( v2Enabled )
84
- {
85
- // Do some work
86
- }
87
- }
83
+ if ( v2Enabled )
84
+ {
85
+ // Do some work
86
+ }
87
+ }
88
88
```
89
89
90
90
## 🌟 Features
@@ -180,11 +180,13 @@ If a name has no associated provider, the global provider is used.
180
180
``` csharp
181
181
// registering the default provider
182
182
await Api .Instance .SetProvider (new LocalProvider ());
183
+
183
184
// registering a named provider
184
185
await Api .Instance .SetProvider (" clientForCache" , new CachedProvider ());
185
186
186
187
// a client backed by default provider
187
- FeatureClient clientDefault = Api .Instance .GetClient ();
188
+ FeatureClient clientDefault = Api .Instance .GetClient ();
189
+
188
190
// a client backed by CachedProvider
189
191
FeatureClient clientNamed = Api .Instance .GetClient (" clientForCache" );
190
192
@@ -213,37 +215,37 @@ You’ll then need to write the provider by implementing the `FeatureProvider` i
213
215
214
216
``` csharp
215
217
public class MyProvider : FeatureProvider
218
+ {
219
+ public override Metadata GetMetadata ()
220
+ {
221
+ return new Metadata (" My Provider" );
222
+ }
223
+
224
+ public override Task <ResolutionDetails <bool >> ResolveBooleanValue (string flagKey , bool defaultValue , EvaluationContext context = null )
216
225
{
217
- public override Metadata GetMetadata ()
218
- {
219
- return new Metadata (" My Provider" );
220
- }
221
-
222
- public override Task <ResolutionDetails <bool >> ResolveBooleanValue (string flagKey , bool defaultValue , EvaluationContext context = null )
223
- {
224
- // resolve a boolean flag value
225
- }
226
-
227
- public override Task <ResolutionDetails <double >> ResolveDoubleValue (string flagKey , double defaultValue , EvaluationContext context = null )
228
- {
229
- // resolve a double flag value
230
- }
231
-
232
- public override Task <ResolutionDetails <int >> ResolveIntegerValue (string flagKey , int defaultValue , EvaluationContext context = null )
233
- {
234
- // resolve an int flag value
235
- }
236
-
237
- public override Task <ResolutionDetails <string >> ResolveStringValue (string flagKey , string defaultValue , EvaluationContext context = null )
238
- {
239
- // resolve a string flag value
240
- }
241
-
242
- public override Task <ResolutionDetails <Value >> ResolveStructureValue (string flagKey , Value defaultValue , EvaluationContext context = null )
243
- {
244
- // resolve an object flag value
245
- }
226
+ // resolve a boolean flag value
246
227
}
228
+
229
+ public override Task <ResolutionDetails <double >> ResolveDoubleValue (string flagKey , double defaultValue , EvaluationContext context = null )
230
+ {
231
+ // resolve a double flag value
232
+ }
233
+
234
+ public override Task <ResolutionDetails <int >> ResolveIntegerValue (string flagKey , int defaultValue , EvaluationContext context = null )
235
+ {
236
+ // resolve an int flag value
237
+ }
238
+
239
+ public override Task <ResolutionDetails <string >> ResolveStringValue (string flagKey , string defaultValue , EvaluationContext context = null )
240
+ {
241
+ // resolve a string flag value
242
+ }
243
+
244
+ public override Task <ResolutionDetails <Value >> ResolveStructureValue (string flagKey , Value defaultValue , EvaluationContext context = null )
245
+ {
246
+ // resolve an object flag value
247
+ }
248
+ }
247
249
```
248
250
249
251
### Develop a hook
0 commit comments