From 5eea677a93020cf3e061a20cb591f122b0e6eb82 Mon Sep 17 00:00:00 2001 From: LORDofDOOM Date: Wed, 21 Mar 2018 01:33:17 +0100 Subject: [PATCH] [Core] Avoid double loading if calling assembly is already loaded on runtime --- TeleSharp.TL/TLContext.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/TeleSharp.TL/TLContext.cs b/TeleSharp.TL/TLContext.cs index db686aa..74b6cec 100644 --- a/TeleSharp.TL/TLContext.cs +++ b/TeleSharp.TL/TLContext.cs @@ -14,13 +14,20 @@ namespace TeleSharp.TL public static void Init() { - Types = new Dictionary(); - Types = (from t in Assembly.GetExecutingAssembly().GetTypes() - where t.IsClass && t.Namespace.StartsWith("TeleSharp.TL") - 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<>)); + try + { + Types = new Dictionary(); + Types = (from t in Assembly.GetExecutingAssembly().GetTypes() + where t.IsClass && t.Namespace.StartsWith("TeleSharp.TL") + 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<>)); + } + catch + { + + } } public static Type getType(int Constructor) {