File tree 1 file changed +10
-19
lines changed
1 file changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -12,38 +12,29 @@ public class SafetyEnumerable<T> : IEnumerable<T>
12
12
/*
13
13
* This class was created to filter List<ISelectable> to an IEnumerable<Column>
14
14
*/
15
- private readonly IEnumerable collection ;
15
+ private readonly IEnumerable _collection ;
16
16
17
17
public SafetyEnumerable ( IEnumerable collection )
18
18
{
19
- this . collection = collection ;
19
+ _collection = collection ;
20
20
}
21
21
22
- #region IEnumerable<T> Members
23
-
24
- IEnumerator < T > IEnumerable < T > . GetEnumerator ( )
22
+ public IEnumerator < T > GetEnumerator ( )
25
23
{
26
- IEnumerator enumerator = collection . GetEnumerator ( ) ;
27
- while ( enumerator . MoveNext ( ) )
24
+ var enumerator = _collection . GetEnumerator ( ) ;
25
+ while ( enumerator . MoveNext ( ) )
28
26
{
29
- object element = enumerator . Current ;
27
+ var element = enumerator . Current ;
30
28
if ( element == null )
31
29
yield return default ( T ) ;
32
- else
33
- if ( typeof ( T ) . IsAssignableFrom ( element . GetType ( ) ) )
34
- yield return ( T ) element ;
30
+ else if ( element is T )
31
+ yield return ( T ) element ;
35
32
}
36
33
}
37
34
38
- #endregion
39
-
40
- #region IEnumerable Members
41
-
42
- public IEnumerator GetEnumerator ( )
35
+ IEnumerator IEnumerable . GetEnumerator ( )
43
36
{
44
- return ( ( IEnumerable < T > ) this ) . GetEnumerator ( ) ;
37
+ return GetEnumerator ( ) ;
45
38
}
46
-
47
- #endregion
48
39
}
49
40
}
You can’t perform that action at this time.
0 commit comments