mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Fix InvalidCast when reading an enum vector
This commit is contained in:
parent
8bbb753c32
commit
403969356f
|
|
@ -201,8 +201,12 @@ namespace TL
|
|||
{
|
||||
int count = reader.ReadInt32();
|
||||
Array array = (Array)Activator.CreateInstance(type, count);
|
||||
for (int i = 0; i < count; i++)
|
||||
array.SetValue(reader.ReadTLValue(elementType), i);
|
||||
if (elementType.IsEnum)
|
||||
for (int i = 0; i < count; i++)
|
||||
array.SetValue(Enum.ToObject(elementType, reader.ReadTLValue(elementType)), i);
|
||||
else
|
||||
for (int i = 0; i < count; i++)
|
||||
array.SetValue(reader.ReadTLValue(elementType), i);
|
||||
return array;
|
||||
}
|
||||
else if (ctorNb < 1024 && !elementType.IsAbstract && elementType.GetCustomAttribute<TLDefAttribute>() is TLDefAttribute attr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue