Sujeet Raman

Sujeet Raman

  • 785
  • 915
  • 330.6k

How to Impliment LaunchDarkly feature management in .net core api

Dec 17 2020 8:40 AM
I would like to add LaunchDarkly feature management in my .net core api.In a real time project how can i add this?
I have one interface file with all features.How will be this interface participate in LD call?
i am confused how to create a generic file for the configuration and call to different controllers! any help will be appreciated!
what I have did in my sample program..
1. I created a flag in the LD website and added below code to main
Configuration ldConfig = LaunchDarkly.Client.Configuration
// TODO: Enter your LaunchDarkly SDK key here
.Default("YOUR_SDK_KEY");
LdClient client = new LdClient(ldConfig);
User user = User.Builder("[email protected]")
.FirstName("Bob")
.LastName("Loblaw")
.Custom("groups", "beta_testers")
.Build();
// TODO: Enter the key for your feature flag key here
var value = client.BoolVariation("YOUR_FEATURE_FLAG_KEY", user, false);
if (value)
{
Console.WriteLine("Showing feature for user " + user.Key);
}
else
{
Console.WriteLine("Not showing feature for user " + user.Key);
}
But now i have a real time api project with huge lines of code, multiple controllers.How can i make this LD class generic? please help me..thanks

Answers (1)