コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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
            });
        }
コード例 #7
0
        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 };
        }