forked from cschladetsch/CsharpFlow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExtension.cs
More file actions
78 lines (66 loc) · 1.79 KB
/
Extension.cs
File metadata and controls
78 lines (66 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// (C) 2012 Christian Schladetsch. See http://www.schladetsch.net/flow/license.txt for Licensing information.
using System;
using System.Collections.Generic;
namespace Flow
{
public static class Extension
{
/// <summary>
/// Returns true if the given sequences contains a reference to the given object.
/// </summary>
/// <returns>
/// True if the sequence described by the enumerable contains a reference to the given object
/// </returns>
/// <param name='list'>
/// The sequence
/// </param>
/// <param name='obj'>
/// The reference to check for
/// </param>
/// <typeparam name='T'>
/// The 1st type parameter.
/// </typeparam>
public static bool ContainsRef<T>(this IEnumerable<T> list, T obj)
{
foreach (var elem in list)
{
if (object.ReferenceEquals(elem, obj))
{
return true;
}
}
return false;
}
/// <summary>
/// Removes a reference from the list
/// </summary>
/// <param name='list'>
/// The list to search
/// </param>
/// <param name='obj'>
/// The object reference to remove.
/// </param>
/// <typeparam name='T'>
/// The 1st type parameter.
/// </typeparam>
public static void RemoveRef<T>(this IList<T> list, T obj)
{
for (var n = 0; n < list.Count; ++n)
{
if (object.ReferenceEquals(list[n], obj))
{
list.RemoveAt(n);
return;
}
}
}
}
public delegate RT Func<RT>();
public delegate RT Func<T0, RT>(T0 t0);
public delegate RT Func<T0, T1, RT>(T0 t0, T1 t1);
public delegate RT Func<T0, T1, T2, RT>(T0 t0, T1 t1, T2 t2);
public delegate RT Func<T0, T1, T2, T3, RT>(T0 t0, T1 t1, T2 t2, T3 t3);
public delegate RT Func<T0, T1, T2, T3, T4, RT>(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4);
public delegate void Action<T0>(T0 t0);
public delegate void Action<T0, T1>(T0 t0, T1 t1);
}