Esempio n. 1
0
        private static void ImportMessageType(XmlDocument xml, MessagePool pool, MessageType type, string nodeName)
        {
            XmlNodeList xmlnode;

            SpSim.Setting.Message message;

            List <SpSim.Setting.Message> output = new List <Setting.Message>();

            bool[] filter = pool.GetFilterByMessageType(type);

            xmlnode = xml.GetElementsByTagName(nodeName);

            foreach (XmlNode xn in xmlnode)
            {
                message = new SpSim.Setting.Message(xn.InnerText, type);

                //Affection requirement
                if (filter[0])
                {
                    if (xn.Attributes[Tags.MESSAGE_FILTER_LIKE] != null)
                    {
                        message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_LIKE].Value);
                    }
                    else
                    {
                        message.Params.Add(affectionWildcard);
                    }
                }

                //Pain Requirement
                if (filter[1])
                {
                    if (xn.Attributes[Tags.MESSAGE_FILTER_PAIN] != null)
                    {
                        message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_PAIN].Value);
                    }
                    else
                    {
                        message.Params.Add(painWildcard);
                    }
                }


                //Contritement Requirement
                if (filter[2])
                {
                    if (xn.Attributes[Tags.MESSAGE_FILTER_CONTRITEMENT] != null)
                    {
                        message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_CONTRITEMENT].Value);
                    }
                    else
                    {
                        message.Params.Add(contWildcard);
                    }
                }

                //Position Requirement
                if (filter[3])
                {
                    if (xn.Attributes[Tags.MESSAGE_FILTER_POSITION] != null)
                    {
                        message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_POSITION].Value);
                    }
                    else
                    {
                        message.Params.Add(reqposWildcard);
                    }
                }

                //Holding Requirement
                if (filter[4])
                {
                    if (xn.Attributes[Tags.MESSAGE_FILTER_HOLDING] != null)
                    {
                        message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_HOLDING].Value + "");
                    }
                    else
                    {
                        message.Params.Add(reqbyWildcard);
                    }
                }

                //Id Requirement
                if (xn.Attributes[Tags.MESSAGE_FILTER_ID] != null)
                {
                    message.Params.Add(xn.Attributes[Tags.MESSAGE_FILTER_ID].Value);
                }
                else
                {
                    message.Params.Add(0);
                }

                output.Add(message);
            }

            pool.AddMessages(output);
        }