예제 #1
0
 public Logic()
 {
     m_first    = null;
     m_second   = null;
     m_operator = Operator.Equals;
 }
예제 #2
0
 public Logic(Fact first, Fact second, Operator op)
 {
     m_first    = first;
     m_second   = second;
     m_operator = op;
 }
예제 #3
0
        public void Read(XmlTextReader reader, Thinker thinker)
        {
            bool done = false;

            while (!done)
            {
                reader.Read();

                if (reader.NodeType == XmlNodeType.EndElement &&
                    reader.Name == "Logic")
                {
                    done = true;
                }
                // Process a start of element node.
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    // Process a text node.
                    if (reader.Name == "Fact1")
                    {
                        while (reader.NodeType != XmlNodeType.Text)
                        {
                            reader.Read();
                        }
                        m_first = thinker.GetFact(reader.Value);
                    }
                    if (reader.Name == "Fact2")
                    {
                        while (reader.NodeType != XmlNodeType.Text)
                        {
                            reader.Read();
                        }
                        m_second = thinker.GetFact(reader.Value);
                    }
                    if (reader.Name == "Operator")
                    {
                        while (reader.NodeType != XmlNodeType.Text)
                        {
                            reader.Read();
                        }
                        switch (reader.Value)
                        {
                        case "And":
                            m_operator = Operator.And;
                            break;

                        case "Equals":
                            m_operator = Operator.Equals;
                            break;

                        case "GreaterThan":
                            m_operator = Operator.GreaterThan;
                            break;

                        case "GreaterThanEquals":
                            m_operator = Operator.GreaterThanEquals;
                            break;

                        case "LessThan":
                            m_operator = Operator.LessThan;
                            break;

                        case "LessThanEquals":
                            m_operator = Operator.LessThanEquals;
                            break;

                        case "NotEqual":
                            m_operator = Operator.NotEqual;
                            break;

                        case "Or":
                            m_operator = Operator.Or;
                            break;

                        case "True":
                            m_operator = Operator.True;
                            break;

                        case "False":
                            m_operator = Operator.False;
                            break;
                        }
                    }
                }
            }            // End while loop
        }