forked from oxyplot/oxyplot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples.cs
More file actions
28 lines (27 loc) · 945 Bytes
/
Copy pathExamples.cs
File metadata and controls
28 lines (27 loc) · 945 Bytes
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
namespace DrawingDemo
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
public static class Examples
{
public static IEnumerable<ExampleInfo> Get()
{
foreach (var type in typeof(Examples).GetTypeInfo().Assembly.DefinedTypes)
{
foreach (var method in type.AsType().GetRuntimeMethods())
{
var exampleAttributes = method.GetCustomAttributes(typeof(ExampleAttribute), true).ToArray();
if (exampleAttributes.Length == 1)
{
var m = method;
yield return
new ExampleInfo(
((ExampleAttribute)exampleAttributes[0]).Title,
() => (Example)m.Invoke(null, null));
}
}
}
}
}
}