[Core] Avoid double loading if calling assembly is already loaded on runtime

This commit is contained in:
LORDofDOOM 2018-03-21 01:33:17 +01:00
parent 81bbe62c5c
commit 5eea677a93

View file

@ -14,13 +14,20 @@ namespace TeleSharp.TL
public static void Init() public static void Init()
{ {
Types = new Dictionary<int, Type>(); try
Types = (from t in Assembly.GetExecutingAssembly().GetTypes() {
where t.IsClass && t.Namespace.StartsWith("TeleSharp.TL") Types = new Dictionary<int, Type>();
where t.IsSubclassOf(typeof(TLObject)) Types = (from t in Assembly.GetExecutingAssembly().GetTypes()
where t.GetCustomAttribute(typeof(TLObjectAttribute)) != null where t.IsClass && t.Namespace.StartsWith("TeleSharp.TL")
select t).ToDictionary(x => ((TLObjectAttribute)x.GetCustomAttribute(typeof(TLObjectAttribute))).Constructor, x => x); where t.IsSubclassOf(typeof(TLObject))
Types.Add(481674261, typeof(TLVector<>)); where t.GetCustomAttribute(typeof(TLObjectAttribute)) != null
select t).ToDictionary(x => ((TLObjectAttribute)x.GetCustomAttribute(typeof(TLObjectAttribute))).Constructor, x => x);
Types.Add(481674261, typeof(TLVector<>));
}
catch
{
}
} }
public static Type getType(int Constructor) public static Type getType(int Constructor)
{ {