Code Coverage Statistics for Source File
Newtonsoft.Json\Linq\JEnumerable.cs
Symbol Coverage: 56.25% (9 of 16)
Branch Coverage: 57.14% (4 of 7)
Cyclomatic Complexity Avg: 1.14 Max:2
Code Lines: 15
Symbol Coverage Trend
View:
L | V | Source |
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using Newtonsoft.Json.Utilities; |
|
6 |
using System.Collections; |
|
7 |
||
8 |
namespace Newtonsoft.Json.Linq |
|
9 |
{ |
|
10 |
/// <summary> |
|
11 |
/// Represents a collection of <see cref="JToken"/> objects. |
|
12 |
/// </summary> |
|
13 |
/// <typeparam name="T">The type of token</typeparam> |
|
14 |
public struct JEnumerable<T> : IJEnumerable<T> where T : JToken |
|
15 |
{ |
|
16 |
/// <summary> |
|
17 |
/// An empty collection of <see cref="JToken"/> objects. |
|
18 |
/// </summary> |
|
19 |
0 |
public static readonly JEnumerable<T> Empty = new JEnumerable<T>(Enumerable.Empty<T>());
|
20 |
||
21 |
private IEnumerable<T> _enumerable; |
|
22 |
||
23 |
/// <summary> |
|
24 |
/// Initializes a new instance of the <see cref="JEnumerable{T}"/> struct. |
|
25 |
/// </summary> |
|
26 |
/// <param name="enumerable">The enumerable.</param> |
|
27 |
public JEnumerable(IEnumerable<T> enumerable) |
|
28 |
{ |
|
29 |
2256 |
ValidationUtils.ArgumentNotNull(enumerable, "enumerable");
|
30 |
||
31 |
2256 |
_enumerable = enumerable;
|
32 |
2256 |
}
|
33 |
||
34 |
/// <summary> |
|
35 |
/// Returns an enumerator that iterates through the collection. |
|
36 |
/// </summary> |
|
37 |
/// <returns> |
|
38 |
/// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection. |
|
39 |
/// </returns> |
|
40 |
public IEnumerator<T> GetEnumerator() |
|
41 |
{ |
|
42 |
2248 |
return _enumerable.GetEnumerator();
|
43 |
2248 |
}
|
44 |
||
45 |
/// <summary> |
|
46 |
/// Returns an enumerator that iterates through a collection. |
|
47 |
/// </summary> |
|
48 |
/// <returns> |
|
49 |
/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection. |
|
50 |
/// </returns> |
|
51 |
IEnumerator IEnumerable.GetEnumerator() |
|
52 |
{ |
|
53 |
695 |
return GetEnumerator();
|
54 |
695 |
}
|
55 |
||
56 |
/// <summary> |
|
57 |
/// Gets the <see cref="IJEnumerable{JToken}"/> with the specified key. |
|
58 |
/// </summary> |
|
59 |
/// <value></value> |
|
60 |
public IJEnumerable<JToken> this[object key] |
|
61 |
{ |
|
62 |
7 |
get { return new JEnumerable<JToken>(Extensions.Values<T, JToken>(_enumerable, key)); }
|
63 |
} |
|
64 |
||
65 |
/// <summary> |
|
66 |
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance. |
|
67 |
/// </summary> |
|
68 |
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> |
|
69 |
/// <returns> |
|
70 |
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>. |
|
71 |
/// </returns> |
|
72 |
public override bool Equals(object obj) |
|
73 |
{ |
|
74 |
0 |
if (obj is JEnumerable<T>)
|
75 |
0 |
return _enumerable.Equals(((JEnumerable<T>)obj)._enumerable);
|
76 |
||
77 |
0 |
return false;
|
78 |
0 |
}
|
79 |
||
80 |
/// <summary> |
|
81 |
/// Returns a hash code for this instance. |
|
82 |
/// </summary> |
|
83 |
/// <returns> |
|
84 |
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
|
85 |
/// </returns> |
|
86 |
public override int GetHashCode() |
|
87 |
{ |
|
88 |
0 |
return _enumerable.GetHashCode();
|
89 |
0 |
}
|
90 |
} |
|
91 |
} |