コード例 #1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            Microsoft.Extensions.Logging.ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            name = name ?? data?.name;

            var clientConfiguration = new LazyLoadConfiguration
            {
                SdkKey = "f3vYCGwC00OC4a_P2E5x4w/U6mbty2Tq0aCDCws85-xvw", // <-- This is the actual SDK Key for your Production environment
                CacheTimeToLiveSeconds = 1
            };
            IConfigCatClient client = new ConfigCatClient(clientConfiguration);

            User user = new User("returning"); // Unique identifier is required. Could be UserID, Email address or SessionID.

            var costumerflag            = client.GetValue("costumerflag", false, user);
            var isAwesomeFeatureEnabled = client.GetValue("isAwesomeFeatureEnabled", false, user);

            Console.WriteLine("costumerflag's value from ConfigCat: " + costumerflag);
            Console.WriteLine("isAwesomeFeatureEnabled's value from ConfigCat: " + isAwesomeFeatureEnabled);

            string responseMessage = costumerflag
                ? $"Welcome back, {name}!"
                : $"Welcome {name}!";

            return(new OkObjectResult(responseMessage));
        }
コード例 #2
0
        public void CreateAnInstance_WhenLazyLoadConfigurationTimeToLiveSecondsIsZero_ShouldThrowArgumentOutOfRangeException()
        {
            var clientConfiguration = new LazyLoadConfiguration
            {
                SdkKey = "hsdrTr4sxbHdSgdhHRZds346hdgsS2vfsgf/GsdrTr4sxbHdSgdhHRZds346hdOPsSgvfsgf",
                CacheTimeToLiveSeconds = 0
            };

            new ConfigCatClient(clientConfiguration);
        }
コード例 #3
0
        public MainViewModel()
        {
            ToggleA = false;
            ToggleB = false;

            VerificarCommand = new Command(ExecuteVerificarCommand);
            AutoCommand      = new Command(ExecuteAutoCommand);
            ManualCommand    = new Command(ExecuteManualCommand);
            LazyCommand      = new Command(ExecuteLazyCommand);


            //Verificar Toggle A
            client_verificar = new ConfigCatClient(Session.ApiKey);


            //Verificar Toggle B - Auto Pooling
            AutoPollConfiguration autoConfiguration = new AutoPollConfiguration
            {
                ApiKey = Session.ApiKey,
                PollIntervalSeconds = 20
            };

            client_auto = new ConfigCatClient(autoConfiguration);


            //Verificar Toggle B - Manual Pooling
            ManualPollConfiguration manualConfiguration = new ManualPollConfiguration
            {
                ApiKey = Session.ApiKey
            };

            client_manual = new ConfigCatClient(manualConfiguration);


            //Verificar Toggle B - Lazy Pooling
            LazyLoadConfiguration lazyConfiguration = new LazyLoadConfiguration
            {
                ApiKey = Session.ApiKey,
                CacheTimeToLiveSeconds = 40
            };

            client_lazy = new ConfigCatClient(lazyConfiguration);
        }
コード例 #4
0
        /// <summary>
        /// Create an instance of BetterConfigClient and setup LazyLoad mode
        /// </summary>
        /// <param name="configuration">Configuration for LazyLoading mode</param>
        /// <exception cref="ArgumentException">When the configuration contains any invalid property</exception>
        /// <exception cref="ArgumentNullException">When the configuration is null</exception>
        public BetterConfigClient(LazyLoadConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            configuration.Validate();

            InitializeClient(configuration);

            var configService = new LazyLoadConfigService(
                new HttpConfigFetcher(configuration.Url, "l-" + version, configuration.LoggerFactory),
                new InMemoryConfigCache(),
                configuration.LoggerFactory,
                TimeSpan.FromSeconds(configuration.CacheTimeToLiveSeconds));

            this.configService = configService;
        }
コード例 #5
0
        public void CreateAnInstance_WhenLazyLoadConfigurationIsNull_ShouldThrowArgumentNullException()
        {
            LazyLoadConfiguration clientConfiguration = null;

            new ConfigCatClient(clientConfiguration);
        }