diff --git a/README.md b/README.md index 0aaeb399..31a47041 100644 --- a/README.md +++ b/README.md @@ -379,19 +379,21 @@ builder.Services.AddOpenFeature(featureBuilder => { You can register a custom provider, such as `InMemoryProvider`, with OpenFeature using the `AddProvider` method. This approach allows you to dynamically resolve services or configurations during registration. ```csharp -services.AddOpenFeature() - .AddProvider(provider => +services.AddOpenFeature(builder => +{ + builder.AddProvider(provider => + { + // Resolve services or configurations as needed + var variants = new Dictionary { { "on", true } }; + var flags = new Dictionary { - // Resolve services or configurations as needed - var configuration = provider.GetRequiredService(); - var flags = new Dictionary - { - { "feature-key", new Flag(configuration.GetValue("FeatureFlags:Key")) } - }; - - // Register a custom provider, such as InMemoryProvider - return new InMemoryProvider(flags); - }); + { "feature-key", new Flag(variants, "on") } + }; + + // Register a custom provider, such as InMemoryProvider + return new InMemoryProvider(flags); + }); +}); ``` #### Adding a Domain-Scoped Provider @@ -399,18 +401,21 @@ services.AddOpenFeature() You can also register a domain-scoped custom provider, enabling configurations specific to each domain: ```csharp -services.AddOpenFeature() - .AddProvider("my-domain", (provider, domain) => +services.AddOpenFeature(builder => +{ + builder.AddProvider("my-domain", (provider, domain) => + { + // Resolve services or configurations as needed for the domain + var variants = new Dictionary { { "on", true } }; + var flags = new Dictionary { - // Resolve services or configurations as needed for the domain - var flags = new Dictionary - { - { $"{domain}-feature-key", new Flag(true) } - }; - - // Register a domain-scoped custom provider such as InMemoryProvider - return new InMemoryProvider(flags); - }); + { $"{domain}-feature-key", new Flag(variants, "on") } + }; + + // Register a domain-scoped custom provider such as InMemoryProvider + return new InMemoryProvider(flags); + }); +}); ```