示例#1
0
        public void TranslateMessage(string _msg)
        {
            try
            {
                // read and parse message
                Stream stream = ComponentMessageParser.GenerateStream(_msg, Encoding.UTF8);
                this.FStream = new StreamReader(stream);
                bool reached_eof = false;
                while (this.HasNext())
                {
                    this.Next();
                    if (this.FValue == ComponentMessage.END_OF_MESSAGE)
                    {
                        reached_eof = true;
                        this.ReleaseRessources();
                        break;
                    }
                    this.ParseComponentMessage();
                }
                if (!reached_eof)
                {
                    this.ReleaseRessources();
                }

                // finalize
                this.ParsedMsg = new ComponentMessage(this.p_msg_pos, this.p_comp_parent_id, this.p_comp_id, this.p_comp_autom_gen,
                                                      this.p_comp_descr, this.p_comp_ref_ids, this.p_comp_params, this.geom_relationships,
                                                      this.p_comp_repres_id, this.p_comp_repres_parent_id, this.p_msg_action_to_take);
            }
            catch (Exception ex)
            {
                this.ReleaseRessources();
                MessageBox.Show(ex.Message, "Error reading message!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public static ComponentMessage FromString(string _msg)
        {
            ComponentMessageParser parser = new ComponentMessageParser();

            parser.TranslateMessage(_msg);

            return(parser.ParsedMsg);
        }