public override void Load(byte[] data) { using (CustomStream ms = new CustomStream(data)) { id = ms.ReadInt(); name = ms.ReadString(); p1 = ms.ReadInt(); p2 = ms.ReadFloat(); p3 = ms.ReadBoolean(); } }
List <T> ConvertByte2EntityList <T>(byte[] buffer) where T : BaseEntity { List <T> dataList = new List <T>(); using (CustomStream cs = new CustomStream(buffer)) { int count = cs.ReadInt(); for (int i = 0; i < count; i++) { int size = cs.ReadInt(); byte[] data = new byte[size]; cs.Read(data, 0, size); dataList.Add(BaseEntity.Instantiation(typeof(T), data) as T); } return(dataList); } }