@@ -57,31 +57,25 @@ static IEnumerable<TSource> Core(IEnumerable<TSource> source, int count)
57
57
}
58
58
}
59
59
60
- private sealed class AssertCountCollectionIterator < T > : CollectionIterator < T >
60
+ private sealed class AssertCountCollectionIterator < T > (
61
+ IEnumerable < T > source ,
62
+ int count
63
+ ) : CollectionIterator < T >
61
64
{
62
- private readonly IEnumerable < T > _source ;
63
- private readonly int _count ;
64
-
65
- public AssertCountCollectionIterator ( IEnumerable < T > source , int count )
66
- {
67
- _source = source ;
68
- _count = count ;
69
- }
70
-
71
65
public override int Count
72
66
{
73
67
get
74
68
{
75
- ArgumentOutOfRangeException . ThrowIfNotEqual ( _source . GetCollectionCount ( ) , _count , "source.Count()" ) ;
76
- return _count ;
69
+ ArgumentOutOfRangeException . ThrowIfNotEqual ( source . GetCollectionCount ( ) , count , "source.Count()" ) ;
70
+ return count ;
77
71
}
78
72
}
79
73
80
74
protected override IEnumerable < T > GetEnumerable ( )
81
75
{
82
- ArgumentOutOfRangeException . ThrowIfNotEqual ( _source . GetCollectionCount ( ) , _count , "source.Count()" ) ;
76
+ ArgumentOutOfRangeException . ThrowIfNotEqual ( source . GetCollectionCount ( ) , count , "source.Count()" ) ;
83
77
84
- foreach ( var item in _source )
78
+ foreach ( var item in source )
85
79
yield return item ;
86
80
}
87
81
@@ -91,27 +85,21 @@ public override void CopyTo(T[] array, int arrayIndex)
91
85
ArgumentOutOfRangeException . ThrowIfNegative ( arrayIndex ) ;
92
86
ArgumentOutOfRangeException . ThrowIfGreaterThan ( arrayIndex , array . Length - Count ) ;
93
87
94
- _ = _source . CopyTo ( array , arrayIndex ) ;
88
+ _ = source . CopyTo ( array , arrayIndex ) ;
95
89
}
96
90
}
97
91
98
- private sealed class AssertCountListIterator < T > : ListIterator < T >
92
+ private sealed class AssertCountListIterator < T > (
93
+ IList < T > source ,
94
+ int count
95
+ ) : ListIterator < T >
99
96
{
100
- private readonly IList < T > _source ;
101
- private readonly int _count ;
102
-
103
- public AssertCountListIterator ( IList < T > source , int count )
104
- {
105
- _source = source ;
106
- _count = count ;
107
- }
108
-
109
97
public override int Count
110
98
{
111
99
get
112
100
{
113
- ArgumentOutOfRangeException . ThrowIfNotEqual ( _source . Count , _count , "source.Count()" ) ;
114
- return _count ;
101
+ ArgumentOutOfRangeException . ThrowIfNotEqual ( source . Count , count , "source.Count()" ) ;
102
+ return count ;
115
103
}
116
104
}
117
105
@@ -120,7 +108,7 @@ protected override IEnumerable<T> GetEnumerable()
120
108
var cnt = ( uint ) Count ;
121
109
for ( var i = 0 ; i < cnt ; i ++ )
122
110
{
123
- yield return _source [ i ] ;
111
+ yield return source [ i ] ;
124
112
}
125
113
}
126
114
@@ -130,15 +118,15 @@ public override void CopyTo(T[] array, int arrayIndex)
130
118
ArgumentOutOfRangeException . ThrowIfNegative ( arrayIndex ) ;
131
119
ArgumentOutOfRangeException . ThrowIfGreaterThan ( arrayIndex , array . Length - Count ) ;
132
120
133
- _source . CopyTo ( array , arrayIndex ) ;
121
+ source . CopyTo ( array , arrayIndex ) ;
134
122
}
135
123
136
124
protected override T ElementAt ( int index )
137
125
{
138
126
ArgumentOutOfRangeException . ThrowIfNegative ( index ) ;
139
127
ArgumentOutOfRangeException . ThrowIfGreaterThanOrEqual ( index , Count ) ;
140
128
141
- return _source [ index ] ;
129
+ return source [ index ] ;
142
130
}
143
131
}
144
132
}
0 commit comments