From 47e973823a0c0695cde4c70e0ab3da27b611d280 Mon Sep 17 00:00:00 2001 From: vlad_neg Date: Wed, 30 May 2018 01:50:44 +0300 Subject: [PATCH] issue#768 fix exception 'Constructor Invalid Or Context.Init Not Called !' --- TLSharp.Core/TelegramClient.cs | 1 - TeleSharp.TL/TLContext.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index dd0593d..3406ee9 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -41,7 +41,6 @@ namespace TLSharp.Core if (store == null) store = new FileSessionStore(); - TLContext.Init(); _apiHash = apiHash; _apiId = apiId; _handler = handler; diff --git a/TeleSharp.TL/TLContext.cs b/TeleSharp.TL/TLContext.cs index db686aa..be43936 100644 --- a/TeleSharp.TL/TLContext.cs +++ b/TeleSharp.TL/TLContext.cs @@ -12,7 +12,7 @@ namespace TeleSharp.TL { private static Dictionary Types; - public static void Init() + static TLContext() { Types = new Dictionary(); Types = (from t in Assembly.GetExecutingAssembly().GetTypes() @@ -22,6 +22,7 @@ namespace TeleSharp.TL 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];