/
axewert
/
WoWDBDefs
Обзор
Документация
Войти
/
axewert
/
WoWDBDefs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
code/C#/DBDefsTest/Utils/BinaryReaderExtensions.cs
14 строк
410 B
Ferronn
end-of-file-fixer
24 июн 2022, 19:48
24 июн 2022, 19:48
e1951e9
Код
Авторство
О чём код?
using System.IO; using System.Runtime.InteropServices; public static class Extensions { public static T Read<T>(this BinaryReader bin) { var bytes = bin.ReadBytes(Marshal.SizeOf(typeof(T))); var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); T ret = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); handle.Free(); return ret; } }