private static void TestSimpleWithDataFile(string sdkKey, string featureKey) { var url = $"https://cdn.optimizely.com/datafiles/{sdkKey}.json"; do { // Fetch the data file using the datafile url string datafile; using (var webClient = new System.Net.WebClient()) { // To refresh on every request webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); datafile = webClient.DownloadString(url); } using (var oc = OptimizelyClient.CreateFromDataFile(datafile)) { // Evaluate a feature flag and a variable var enabled1 = oc.IsFeatureEnabled(new OptimizelyFeatureParameters(featureKey).WithArgument("IsLocal", true)); var enabled2 = oc.IsFeatureEnabled(new OptimizelyFeatureParameters(featureKey).WithArgument("IsLocal", false)); Console.WriteLine($"{featureKey} audience local is {enabled1}"); Console.WriteLine($"{featureKey} audience not local is {enabled2}"); } Thread.Sleep(5000); } while (true); }
private static void TestWithUpdater(string sdkKey, string featureKey) { // Run datafile polling with 5 sec interval var cfg = OptimizelyClient.Create(new OptimizelyClientCreateParameters(sdkKey).WithPollingPeriod(5)); do { Thread.Sleep(5000); // Evaluate a feature flag and a variable var enabled = cfg.IsFeatureEnabled(new OptimizelyFeatureParameters(featureKey).WithArgument("IsLocal", true)); Console.WriteLine($"{featureKey} audience local is {enabled}"); } while (true); }