[Core] Add proper method to check double loading

This commit is contained in:
LORDofDOOM 2018-03-22 03:53:52 +01:00
parent 5e060a160b
commit e52f1caeee

View file

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