private byte[] Decode(byte[] data, ref B3Element element) { if (data.Length == 0 || !Enum.IsDefined(typeof(DecodeType), data[0])) { IsChecked = false; return(new byte[0]); } int length = GetLength(data[0]); if (length == 0 || data.Length < length) { IsChecked = false; return(new byte[0]); } switch ((DecodeType)data[0]) { case DecodeType.CenterCode: element.CenterCode = ElementDecodeFunctions.CenterCode(data); break; case DecodeType.ClientCode: element.ClientCode = ElementDecodeFunctions.ClientCode(data); break; case DecodeType.IPPort: element.IPPort = ElementDecodeFunctions.IPPort(data); break; case DecodeType.Interval: element.Interval = ElementDecodeFunctions.Interval(data); break; } return(BytesUtil.SubBytes(data, length)); }
public B3Element Read() { B3Element element = new B3Element(); do { LeftData = Decode(LeftData, ref element); } while (LeftData.Length > 0 && IsChecked); return(element); }