Debian Codegraph @

symbols/pdb/Test/Mono.Cecil.Tests/Linq.cs

raw
1 using System;
2 using System.Collections.Generic;
3
4 #if !NET_3_5 && !NET_4_0
5
6 namespace System {
7
8 delegate TResult Func<T, TResult> (T t);
9 }
10
11 namespace System.Runtime.CompilerServices {
12
13 [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
14 sealed class ExtensionAttribute : Attribute {
15 }
16 }
17
18 namespace System.Linq {
19
20 static class Enumerable {
21
22 public static IEnumerable<TRet> Select<TItem, TRet> (this IEnumerable<TItem> self, Func<TItem, TRet> selector)
23 {
24 foreach (var item in self)
25 yield return selector (item);
26 }
27
28 public static IEnumerable<T> Where<T> (this IEnumerable<T> self, Func<T, bool> predicate)
29 {
30 foreach (var item in self)
31 if (predicate (item))
32 yield return item;
33 }
34
35 public static T First<T> (this IEnumerable<T> self)
36 {
37 using (var enumerator = self.GetEnumerator ()) {
38 if (!enumerator.MoveNext ())
39 throw new InvalidOperationException ();
40
41 return enumerator.Current;
42 }
43 }
44 }
45 }
46
47 #endif