TLSharp/TeleSharp.TL/TLContext.cs

29 lines
924 B
C#
Raw Normal View History

2016-09-24 17:08:26 +03:30
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace TeleSharp.TL
{
public static class TLContext
{
private static Dictionary<int, Type> Types;
public static void Init()
{
Types = new Dictionary<int, Type>();
Types = (from t in Assembly.GetExecutingAssembly().GetTypes()
2017-04-13 13:38:01 +07:00
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);
2016-09-24 17:08:26 +03:30
Types.Add(481674261, typeof(TLVector<>));
}
2017-04-13 13:38:01 +07:00
2016-09-24 17:08:26 +03:30
public static Type getType(int Constructor)
{
return Types[Constructor];
}
}
2017-04-13 13:38:01 +07:00
}