mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
TgSharp.TL: fix invalid Context type initialization for TLVector
Fixes https://github.com/nblockchain/TgSharp/issues/15
This commit is contained in:
parent
73313ae199
commit
3ea897402c
|
|
@ -12,6 +12,7 @@ namespace TgSharp.TL
|
|||
public static object DeserializeObject(BinaryReader reader)
|
||||
{
|
||||
int Constructor = reader.ReadInt32();
|
||||
|
||||
object obj;
|
||||
Type t = null;
|
||||
try
|
||||
|
|
@ -21,8 +22,9 @@ namespace TgSharp.TL
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
|
||||
throw new InvalidDataException("Invalid constructor, or invalid TLContext static initialization", ex);
|
||||
}
|
||||
|
||||
if (t.IsSubclassOf(typeof(TLMethod)))
|
||||
{
|
||||
((TLMethod)obj).DeserializeResponse(reader);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,19 @@ namespace TgSharp.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<>));
|
||||
|
||||
|
||||
var vectorTypeId = 481674261;
|
||||
var genericVectorType = typeof (TLVector<>);
|
||||
|
||||
Type type;
|
||||
if (Types.TryGetValue(vectorTypeId, out type)) {
|
||||
if (type != genericVectorType && type != typeof(TLVector)) {
|
||||
throw new InvalidOperationException ($"Type {vectorTypeId} should have been a TLVector type but was {type}");
|
||||
}
|
||||
} else {
|
||||
Types [vectorTypeId] = genericVectorType;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type getType(int Constructor)
|
||||
|
|
|
|||
Loading…
Reference in a new issue