Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / class / System.Json.Microsoft / System.Json / JsonValueLinqExtensions.cs
1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Diagnostics.CodeAnalysis;
6
7 namespace System.Json
8 {
9     /// <summary>
10     /// This class extends the funcionality of the <see cref="JsonValue"/> type for better Linq support . 
11     /// </summary>
12     [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Linq is a technical name.")]
13     [EditorBrowsable(EditorBrowsableState.Never)]
14     public static class JsonValueLinqExtensions
15     {
16         /// <summary>
17         /// Extension method for creating a <see cref="JsonValue"/> from an <see cref="IEnumerable{T}"/> collection of <see cref="JsonValue"/> types.
18         /// </summary>
19         /// <param name="items">The enumerable instance.</param>
20         /// <returns>A <see cref="JsonArray"/> created from the specified items.</returns>
21         public static JsonArray ToJsonArray(this IEnumerable<JsonValue> items)
22         {
23             return new JsonArray(items);
24         }
25
26         /// <summary>
27         /// Extension method for creating a <see cref="JsonValue"/> from an <see cref="IEnumerable{T}"/> collection of <see cref="KeyValuePair{K,V}"/> of <see cref="String"/> and <see cref="JsonValue"/> types.
28         /// </summary>
29         /// <param name="items">The enumerable instance.</param>
30         /// <returns>A <see cref="JsonValue"/> created from the specified items.</returns>
31         [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "JsonValue implements the nested type in param.")]
32         public static JsonObject ToJsonObject(this IEnumerable<KeyValuePair<string, JsonValue>> items)
33         {
34             return new JsonObject(items);
35         }
36     }
37 }