-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (53 loc) · 1.87 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (53 loc) · 1.87 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
using System;
using System.Reflection;
using System.Threading;
namespace Attrs
{
public class Program
{
public static void Main()
{
new Thread(ProcessAttributes).Start();
void ProcessAttributes()
{
Console.WriteLine("Start");
var loops = 0;
while (true)
{
Thread.Sleep(15);
int typesNo = 0;
int fieldsNo = 0;
int attrNo = 0;
Assembly assembly = Assembly.GetExecutingAssembly();
foreach (var type in assembly.GetTypes())
{
typesNo++;
var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var field in fields)
{
fieldsNo++;
try
{
var attributes = field.GetCustomAttributes(false);
foreach (var attr in attributes)
{
attrNo++;
}
}
catch (Exception e)
{
Console.WriteLine("Error during processing attributes" + e.ToString());
}
}
}
loops++;
Console.WriteLine($"types={typesNo}, fields={fieldsNo}, attr={attrNo}, {loops}");
}
}
while (true)
{
Thread.Sleep(1000);
}
}
}
}