private static async Task AddValueProviderAsync(ValueProviderFactoryContext context) { var request = context.ActionContext.HttpContext.Request; IFormCollection formCollection; try { formCollection = await request.ReadFormAsync(); } catch (InvalidDataException ex) { // ReadFormAsync can throw InvalidDataException if the form content is malformed. // Wrap it in a ValueProviderException that the CompositeValueProvider special cases. throw new ValueProviderException(Resources.FormatFailedToReadRequestForm(ex.Message), ex); } catch (IOException ex) { // ReadFormAsync can throw IOException if the client disconnects. // Wrap it in a ValueProviderException that the CompositeValueProvider special cases. throw new ValueProviderException(Resources.FormatFailedToReadRequestForm(ex.Message), ex); } var valueProvider = new JQueryFormValueProvider( BindingSource.Form, JQueryKeyValuePairNormalizer.GetValues(formCollection, formCollection.Count), CultureInfo.CurrentCulture); context.ValueProviders.Add(valueProvider); }
private static async Task AddValueProviderAsync(ValueProviderFactoryContext context) { var request = context.ActionContext.HttpContext.Request; var valueProvider = new JQueryFormValueProvider( BindingSource.Form, await GetValueCollectionAsync(request), CultureInfo.CurrentCulture); context.ValueProviders.Add(valueProvider); }
public void Filter_ExcludesItself() { // Arrange var dictionary = new Dictionary <string, StringValues>(); var provider = new JQueryFormValueProvider(BindingSource.Form, dictionary, CultureInfo.CurrentCulture); // Act var result = provider.Filter(); // Assert Assert.Null(result); }
private static async Task AddValueProviderAsync(ValueProviderFactoryContext context) { var request = context.ActionContext.HttpContext.Request; var formCollection = await request.ReadFormAsync(); var valueProvider = new JQueryFormValueProvider( BindingSource.Form, JQueryKeyValuePairNormalizer.GetValues(formCollection, formCollection.Count), CultureInfo.CurrentCulture); context.ValueProviders.Add(valueProvider); }
protected override IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, Dictionary <string, StringValues> values, CultureInfo culture) { var emptyValueProvider = new JQueryFormValueProvider(bindingSource, new Dictionary <string, StringValues>(), culture); var valueProvider = new JQueryFormValueProvider(bindingSource, values, culture); return(new CompositeValueProvider() { emptyValueProvider, valueProvider }); }
protected override IEnumerableValueProvider GetEnumerableValueProvider( BindingSource bindingSource, Dictionary<string, StringValues> values, CultureInfo culture) { var emptyValueProvider = new JQueryFormValueProvider(bindingSource, new Dictionary<string, StringValues>(), culture); var valueProvider = new JQueryFormValueProvider(bindingSource, values, culture); return new CompositeValueProvider() { emptyValueProvider, valueProvider }; }