-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilderReflector.cs
More file actions
38 lines (32 loc) · 1.15 KB
/
BuilderReflector.cs
File metadata and controls
38 lines (32 loc) · 1.15 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
using System;
using System.Linq;
using System.Reflection;
namespace reflection
{
public class BuilderReflector
{
public static object AddBuilderReflector(){
var typesWithMyAttribute =
// Note the AsParallel here, this will parallelize everything after.
from a in AppDomain.CurrentDomain.GetAssemblies().AsParallel()
from t in a.GetTypes()
let attributes = t.GetCustomAttributes(typeof(BuilderReflectionAttribute), true)
where attributes != null && attributes.Length > 0
select new QueryClass(){ tt = t };
foreach (QueryClass targetClass in typesWithMyAttribute){
var fields = targetClass.tt.GetFields( BindingFlags.NonPublic | BindingFlags.Instance);
foreach (FieldInfo field in fields){
Console.WriteLine(field.Name);
}
fields = targetClass.tt.GetFields( );
foreach (FieldInfo field in fields){
Console.WriteLine(field.Name);
}
}
return null;
}
class QueryClass{
public Type tt;
}
}
}