PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/WCFWebApi/src/Microsoft.Json/System/Json/JsonValueLinqExtensions.cs

#
C# | 36 lines | 17 code | 3 blank | 16 comment | 0 complexity | a2a8fda9ff3d0c3985f7b03e161368ad MD5 | raw file
 1// <copyright file="JsonValueLinqExtensions.cs" company="Microsoft Corporation">
 2//   Copyright (c) Microsoft Corporation.  All rights reserved.
 3// </copyright>
 4
 5namespace System.Json
 6{
 7    using System.Collections.Generic;
 8
 9    /// <summary>
10    /// This class extends the funcionality of the <see cref="JsonValue"/> type for better Linq support . 
11    /// </summary>
12    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Linq is a technical name.")]
13    public static class JsonValueLinqExtensions
14    {
15        /// <summary>
16        /// Extension method for creating a <see cref="JsonValue"/> from an <see cref="IEnumerable{T}"/> collection of <see cref="JsonValue"/> types.
17        /// </summary>
18        /// <param name="items">The enumerable instance.</param>
19        /// <returns>A <see cref="JsonArray"/> created from the specified items.</returns>
20        public static JsonArray ToJsonArray(this IEnumerable<JsonValue> items)
21        {
22            return new JsonArray(items);
23        }
24
25        /// <summary>
26        /// 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.
27        /// </summary>
28        /// <param name="items">The enumerable instance.</param>
29        /// <returns>A <see cref="JsonValue"/> created from the specified items.</returns>
30        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "JsonValue implements the nested type in param.")]
31        public static JsonObject ToJsonObject(this IEnumerable<KeyValuePair<string, JsonValue>> items)
32        {
33            return new JsonObject(items);
34        }
35    }
36}