Пример #1
0
        public async Task Invoke(HttpContext context)
        {
            if (!IsXabarilRequest(context.Request))
            {
                await _next(context);

                return;
            }
            else
            {
            }

            var statusCode  = HttpStatusCode.OK;
            var featureName = context.Request.Query["featureName"];
            var json        = String.Empty;

            try
            {
                var isEnabled = await _feturesService.IsEnabledAsync(featureName).ConfigureAwait(false);

                var data = new { isEnabled = isEnabled };
                json = JsonConvert.SerializeObject(data);
            }
            catch (ArgumentException)
            {
                statusCode = HttpStatusCode.NotFound;
            }

            await WriteResponseAsync(
                context,
                json,
                "application/json",
                statusCode);
        }
Пример #2
0
 public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
 {
     if (!await _featuresService.IsEnabledAsync(_featureName))
     {
         context.Result = new NotFoundResult()
         {
         };
     }
     else
     {
         await next();
     }
 }
Пример #3
0
        public async Task <IActionResult> Index()
        {
            if (await _features.IsEnabledAsync("MyFeature"))
            {
                ViewData["Message"] = "My Feature Is Active";
            }
            else
            {
                ViewData["Message"] = "My Feature Is NOT Active";
            }

            return(View());
        }
Пример #4
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var childContent = await output.GetChildContentAsync();

            if (!childContent.IsEmptyOrWhiteSpace)
            {
                var isActive = await _featuresService.IsEnabledAsync(FeatureName);

                if (!isActive)
                {
                    output.Content.SetContent(string.Empty);
                }
            }
        }
Пример #5
0
            public bool Accept(ActionConstraintContext context)
            {
                var isEnabled = _featureService.IsEnabledAsync(_featureName).Result;

                return(isEnabled);
            }