public static void TryParse(byte[] input, out CGMessage cgMessage) { BinaryReader reader = new BinaryReader(new MemoryStream(input)); cgMessage = new CGMessage(reader); switch (cgMessage.messageType) { case MessageType.Type1: cgMessage = Module1.ContinueParse(reader, cgMessage); break; case MessageType.Type2: cgMessage = Module2.ContinueParse(reader, cgMessage); break; case MessageType.Type3: cgMessage = Module3.ContinueParse(reader, cgMessage); break; default: break; } cgMessage.ParseTailingFields(reader); }
public static Module2 ContinueParse(BinaryReader input, CGMessage cgMessage) { Module2 feature = new Module2(cgMessage); feature.value = Encoding.UTF8.GetString(input.ReadBytes(cgMessage.dataLength)); return(feature); }
public CGMessage GetMessage(string value) { CGMessage message = null; switch (Program.CurrentMessageType) { case MessageType.Type1: message = new Module1(value); break; case MessageType.Type2: message = new Module2(value); break; case MessageType.Type3: message = new Module3(value); break; default: break; } return(message); }