public async Task Dispatch(RequestDispatcherContext context) { var owinContext = new OwinContext(context.OwinEnvironment); var form = await owinContext.ReadFormSafeAsync(); var requestedMetrics = new HashSet <string>(form.GetValues("metrics[]") ?? new string[0]); var page = new StubPage(); page.Assign(context); var metrics = DashboardMetrics.GetMetrics().Where(x => requestedMetrics.Contains(x.Name)); var result = new Dictionary <string, Metric>(); foreach (var metric in metrics) { var value = metric.Func(page); result.Add(metric.Name, value); } var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new JsonConverter[] { new StringEnumConverter { CamelCaseText = true } } }; var serialized = JsonConvert.SerializeObject(result, settings); owinContext.Response.ContentType = "application/json"; await owinContext.Response.WriteAsync(serialized); }
public async Task Dispatch(DashboardContext context) { var requestedMetrics = await context.Request.GetFormValuesAsync("metrics[]").ConfigureAwait(false); var page = new StubPage(); page.Assign(context); var metrics = DashboardMetrics.GetMetrics().Where(x => requestedMetrics.Contains(x.Name)); var result = new Dictionary <string, Metric>(); foreach (var metric in metrics) { var value = metric.Func(page); result.Add(metric.Name, value); } var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new JsonConverter[] { new StringEnumConverter { CamelCaseText = true } } }; var serialized = JsonConvert.SerializeObject(result, settings); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(serialized).ConfigureAwait(false); }
public async Task Dispatch(RequestDispatcherContext context) { var owinContext = new OwinContext(context.OwinEnvironment); var form = await owinContext.Request.ReadFormAsync(); var requestedMetrics = new HashSet<string>(form.GetValues("metrics[]") ?? new string[0]); var page = new StubPage(); page.Assign(context); var metrics = DashboardMetrics.GetMetrics().Where(x => requestedMetrics.Contains(x.Name)); var result = new Dictionary<string, Metric>(); foreach (var metric in metrics) { var value = metric.Func(page); result.Add(metric.Name, value); } var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new JsonConverter[]{ new StringEnumConverter { CamelCaseText = true } } }; var serialized = JsonConvert.SerializeObject(result, settings); owinContext.Response.ContentType = "application/json"; await owinContext.Response.WriteAsync(serialized); }
public void Test_OnlyForWidgets() { var filter = new WidgetFilter("SomeZone", "/"); var page = new StubPage(); Assert.False(filter.Match(page)); }
public void ViewModelLocator_SetViewModelType_Should_Set_Binding_Context() { var view = new StubPage(); ViewModelLocator.SetViewModelType(view, _viewModel.GetType()); view.BindingContext.Should().Be(_viewModel); }
public void ViewModelLocator_SetAutowireViewModel_Should_Set_Binding_Context() { var view = new StubPage(); ViewModelLocator.SetAutowireViewModel(view, true); view.BindingContext.Should().Be(_viewModel); }
public void ViewModelLocator_GetAutowireViewModel_Should_Be_True_When_Set() { var view = new StubPage(); ViewModelLocator.SetAutowireViewModel(view, true); Assert.True(ViewModelLocator.GetAutowireViewModel(view)); ViewModelLocator.GetAutowireViewModel(view).Should().BeTrue(); }
public async Task Dispatch(DashboardContext context) { var page = new StubPage(); page.Assign(context); var monitor = context.Monitor; var pipelines = monitor.GetMetrics(); var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Converters = new JsonConverter[] { new StringEnumConverter { NamingStrategy = new CamelCaseNamingStrategy() } } }; var serialized = JsonConvert.SerializeObject(pipelines, settings); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(serialized); }
public async Task Dispatch(DashboardContext context) { var requestedMetrics = await context.Request.GetFormValuesAsync("metrics[]"); var page = new StubPage(); page.Assign(context); var metrics = DashboardMetrics.GetMetrics().Where(x => requestedMetrics.Contains(x.Name)); var result = new Dictionary <string, Metric>(); foreach (var metric in metrics) { var value = metric.Func(page); result.Add(metric.Name, value); } var serialized = JsonSerializer.Serialize(result); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(serialized); }