private bool Validation(PacketSize p) { if (p.Header[0] == 0x01 && p.Header[1] == 0x02 && p.Header[2] == 0x03 && p.Header[3] == 0x04) { return(true); } return(false); }
public static PacketSize Create(int size) { PacketSize ret = new PacketSize(); ret.Header[0] = 0x01; ret.Header[1] = 0x02; ret.Header[2] = 0x03; ret.Header[3] = 0x04; ret.Size = size; return(ret); }
public static PacketSize FromBytes(byte[] data) { PacketSize ret = new PacketSize(); if (data.Length != 8) { return(null); } for (int i = 0; i < ret.Header.Length; i++) { ret.Header[i] = data[i]; } if (ret.Validation(ret) == false) { return(null); } ret.Size = BitConverter.ToInt32(data, 4); return(ret); }