-
Notifications
You must be signed in to change notification settings - Fork 0
/
TLContext.cs
33 lines (29 loc) · 974 Bytes
/
TLContext.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TLSchema;
namespace TLSchema
{
public static class TLContext
{
private static Dictionary<int, Type> Types;
static TLContext()
{
var allTypes = typeof(TLContext).Assembly.GetTypes();
Types = new Dictionary<int, Type>();
Types = (from t in allTypes
where t.IsClass
where t.IsSubclassOf(typeof(TLObject))
where t.GetCustomAttribute(typeof(TLObjectAttribute)) != null
select t).ToDictionary(x => ((TLObjectAttribute)x.GetCustomAttribute(typeof(TLObjectAttribute))).Constructor, x => x);
//Types.Add(481674261, typeof(TLVector<>));
}
public static Type getType(int Constructor)
{
return Types[Constructor];
}
}
}