コード例 #1
0
        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);
        }
コード例 #2
0
        public static Module3 ContinueParse(BinaryReader input, CGMessage cgMessage)
        {
            Module3 feature = new Module3(cgMessage);

            feature.value = Encoding.UTF8.GetString(input.ReadBytes(cgMessage.dataLength));

            return(feature);
        }
コード例 #3
0
        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);
        }