mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-01-20 23:40:22 +01:00
fix (uint) unboxing on fields "int flags" (improved)
This commit is contained in:
parent
bedb44582e
commit
8bbb753c32
|
|
@ -1202,10 +1202,12 @@ namespace WTelegram
|
|||
lock (_accessHashes)
|
||||
_accessHashes.GetOrCreate(typeof(T))[id] = access_hash;
|
||||
}
|
||||
internal void UpdateAccessHash(object obj, Type type, object access_hash)
|
||||
internal void MonitorField(FieldInfo fieldInfo, object obj, object access_hash)
|
||||
{
|
||||
if (!CollectAccessHash) return;
|
||||
if (fieldInfo.Name != "access_hash") return;
|
||||
if (access_hash is not long accessHash) return;
|
||||
var type = fieldInfo.ReflectedType;
|
||||
if (type.GetField("id") is not FieldInfo idField) return;
|
||||
if (idField.GetValue(obj) is not long id)
|
||||
if (idField.GetValue(obj) is not int idInt) return;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace TL
|
|||
if (((ifFlag = field.GetCustomAttribute<IfFlagAttribute>()) != null) && (flags & (1U << ifFlag.Bit)) == 0) continue;
|
||||
object value = field.GetValue(obj);
|
||||
writer.WriteTLValue(value, field.FieldType);
|
||||
if (field.Name == "flags" && field.FieldType.IsEnum) flags = (uint)value;
|
||||
if (field.FieldType.IsEnum && field.Name == "flags") flags = (uint)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +70,8 @@ namespace TL
|
|||
if (((ifFlag = field.GetCustomAttribute<IfFlagAttribute>()) != null) && (flags & (1U << ifFlag.Bit)) == 0) continue;
|
||||
object value = reader.ReadTLValue(field.FieldType);
|
||||
field.SetValue(obj, value);
|
||||
if (field.Name == "flags" && field.FieldType.IsEnum) flags = (uint)value;
|
||||
else if (field.Name == "access_hash") reader.Client?.UpdateAccessHash(obj, type, value);
|
||||
if (field.FieldType.IsEnum && field.Name == "flags") flags = (uint)value;
|
||||
reader.Client?.MonitorField(field, obj, value);
|
||||
}
|
||||
return (IObject)obj;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue