forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouteDataValueProvider.cs
More file actions
27 lines (24 loc) · 1.01 KB
/
Copy pathRouteDataValueProvider.cs
File metadata and controls
27 lines (24 loc) · 1.01 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
// 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;
using System.Web.Http.Routing;
namespace System.Web.Http.ValueProviders.Providers
{
public class RouteDataValueProvider : NameValuePairsValueProvider
{
public RouteDataValueProvider(HttpActionContext actionContext, CultureInfo culture)
: base(GetRouteValues(actionContext.ControllerContext.RouteData), culture)
{
}
internal static IEnumerable<KeyValuePair<string, string>> GetRouteValues(IHttpRouteData routeData)
{
foreach (KeyValuePair<string, object> pair in routeData.Values)
{
string value = (pair.Value == null) ? null : pair.Value.ToString();
yield return new KeyValuePair<string, string>(pair.Key, value);
}
}
}
}