forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpRouteValueDictionary.cs
More file actions
53 lines (49 loc) · 1.93 KB
/
Copy pathHttpRouteValueDictionary.cs
File metadata and controls
53 lines (49 loc) · 1.93 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 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.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Web.Http.Internal;
namespace System.Web.Http.Routing
{
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable", Justification = "This class will never be serialized.")]
public class HttpRouteValueDictionary : Dictionary<string, object>
{
public HttpRouteValueDictionary()
: base(StringComparer.OrdinalIgnoreCase)
{
}
public HttpRouteValueDictionary(IDictionary<string, object> dictionary)
: base(StringComparer.OrdinalIgnoreCase)
{
if (dictionary != null)
{
foreach (KeyValuePair<string, object> current in dictionary)
{
Add(current.Key, current.Value);
}
}
}
public HttpRouteValueDictionary(object values)
: base(StringComparer.OrdinalIgnoreCase)
{
IDictionary<string, object> valuesAsDictionary = values as IDictionary<string, object>;
if (valuesAsDictionary != null)
{
foreach (KeyValuePair<string, object> current in valuesAsDictionary)
{
Add(current.Key, current.Value);
}
}
else if (values != null)
{
foreach (PropertyHelper property in PropertyHelper.GetProperties(values))
{
// Extract the property values from the property helper
// The advantage here is that the property helper caches fast accessors.
Add(property.Name, property.GetValue(values));
}
}
}
}
}