blob: 6d0bd57375f91cbdab1a0408360f777afc5f6bbc (
plain)
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
|
using System;
using System.Collections.Generic;
public class Test {
List<object> annotations = new List<object> ();
public IEnumerable<T> Annotations<T> () where T : class
{
foreach (T o in Annotations (typeof (T)))
yield return o;
}
public IEnumerable<object> Annotations (Type type)
{
if (annotations == null)
yield break;
foreach (object o in annotations)
if (o.GetType () == type)
yield return o;
}
public static void Main ()
{
var test = new Test ();
test.Annotations<Test> ();
}
}
|