forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryStringValueProviderFactory.cs
More file actions
35 lines (28 loc) · 1.28 KB
/
Copy pathQueryStringValueProviderFactory.cs
File metadata and controls
35 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Globalization;
using System.Web.Http.Controllers;
namespace System.Web.Http.ValueProviders.Providers
{
public class QueryStringValueProviderFactory : ValueProviderFactory, IUriValueProviderFactory
{
private const string RequestLocalStorageKey = "{8572540D-3BD9-46DA-B112-A1E6C9086003}";
public override IValueProvider GetValueProvider(HttpActionContext actionContext)
{
if (actionContext == null)
{
throw Error.ArgumentNull("actionContext");
}
// Only parse the query string once-per request.
QueryStringValueProvider provider;
IDictionary<string, object> storage = actionContext.Request.Properties;
if (!storage.TryGetValue(RequestLocalStorageKey, out provider))
{
provider = new QueryStringValueProvider(actionContext, CultureInfo.InvariantCulture);
storage[RequestLocalStorageKey] = provider;
}
return provider;
}
}
}