Esempio n. 1
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);
            string typeName     = null;
            string propertyName = null;
            string str3         = null;

            foreach (property_t _t in properties)
            {
                if (_t.name == "Operator")
                {
                    str3 = _t.value;
                }
                else if (_t.name == "Opl")
                {
                    if (_t.value.IndexOf('(') == -1)
                    {
                        this.m_opl = LoadLeft(_t.value, ref propertyName, null);
                    }
                    else
                    {
                        this.m_opl_m = behaviac.Action.LoadMethod(_t.value);
                    }
                }
                else if (_t.name == "Opr")
                {
                    this.m_opr = LoadRight(_t.value, propertyName, ref typeName);
                }
            }
            if ((!string.IsNullOrEmpty(str3) && ((this.m_opl != null) || (this.m_opl_m != null))) && (this.m_opr != null))
            {
                this.m_comparator = Create(typeName, str3, this.m_opl, this.m_opr);
            }
        }
Esempio n. 2
0
        public static VariableComparator Create(string comparionOperator, Property lhs, CMethodBase lhs_m, Property rhs, CMethodBase rhs_m)
        {
            E_VariableComparisonType comparisonType = VariableComparator.ParseComparisonType(comparionOperator);

            VariableComparator pComparator = VariableComparator.Create(lhs, lhs_m, rhs, rhs_m);

            pComparator.SetComparisonType(comparisonType);

            return(pComparator);
        }
Esempio n. 3
0
        public static VariableComparator Create(string typeName, string comparionOperator, Property lhs, Property rhs)
        {
            E_VariableComparisonType type = VariableComparator.ParseComparisonType(comparionOperator);

            if (Agent.IsAgentClassName(typeName))
            {
                typeName = "void*";
            }
            VariableComparator comparator = VariableComparator.Create(typeName, lhs, rhs);

            comparator.SetComparisonType(type);
            return(comparator);
        }
Esempio n. 4
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);
            string typeName     = null;
            string propertyName = null;
            string text         = null;

            using (List <property_t> .Enumerator enumerator = properties.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    property_t current = enumerator.get_Current();
                    if (current.name == "Operator")
                    {
                        text = current.value;
                    }
                    else if (current.name == "Opl")
                    {
                        int num = current.value.IndexOf('(');
                        if (num == -1)
                        {
                            this.m_opl = Condition.LoadLeft(current.value, ref propertyName, null);
                        }
                        else
                        {
                            this.m_opl_m = Action.LoadMethod(current.value);
                        }
                    }
                    else if (current.name == "Opr")
                    {
                        this.m_opr = Condition.LoadRight(current.value, propertyName, ref typeName);
                    }
                    else if (current.name == "BinaryOperator")
                    {
                        if (current.value == "Or")
                        {
                            this.m_bAnd = false;
                        }
                        else if (current.value == "And")
                        {
                            this.m_bAnd = true;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(text) && (this.m_opl != null || this.m_opl_m != null) && this.m_opr != null)
            {
                this.m_comparator = Condition.Create(typeName, text, this.m_opl, this.m_opr);
            }
        }
Esempio n. 5
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool bResult = false;

            if (opl != null)
            {
                Agent      agent_left = pAgent;
                ParentType pt         = opl.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl.GetInstanceNameString()));
                }

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

                bResult = comparator.Execute(agent_left, agent_right);
            }
            else if (opl_m != null)
            {
                ParentType pt         = opl_m.GetParentType();
                Agent      agent_left = pAgent;
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl_m.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl_m.GetInstanceNameString()));
                }

                object returnValue = opl_m.run(agent_left, pAgent);

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_right.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

                bResult = comparator.Execute(returnValue, agent_left, agent_right);
            }

            return(bResult);
        }
Esempio n. 6
0
        public static VariableComparator Create(string typeName, string comparionOperator, Property lhs, Property rhs)
        {
            E_VariableComparisonType comparisonType = VariableComparator.ParseComparisonType(comparionOperator);

            //bool bAgentPtr = false;
            //it might be par or the right value of condition/assignment
            if (Agent.IsAgentClassName(typeName))
            {
                //bAgentPtr = true;
                typeName = "void*";
            }

            VariableComparator pComparator = VariableComparator.Create(typeName, lhs, rhs);

            pComparator.SetComparisonType(comparisonType);

            return(pComparator);
        }
Esempio n. 7
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool result = false;

            if (opl != null)
            {
                Agent      agent      = pAgent;
                ParentType parentType = opl.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agent = Agent.GetInstance(opl.GetInstanceNameString(), agent.GetContextId());
                }
                Agent agentR = pAgent;
                parentType = opr.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agentR = Agent.GetInstance(opr.GetInstanceNameString(), agent.GetContextId());
                }
                result = comparator.Execute(agent, agentR);
            }
            else if (opl_m != null)
            {
                ParentType parentType2 = opl_m.GetParentType();
                Agent      agent2      = pAgent;
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent2 = Agent.GetInstance(opl_m.GetInstanceNameString(), agent2.GetContextId());
                }
                object lhs    = opl_m.run(agent2, pAgent);
                Agent  agent3 = pAgent;
                parentType2 = opr.GetParentType();
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent3 = Agent.GetInstance(opr.GetInstanceNameString(), agent3.GetContextId());
                }
                result = comparator.Execute(lhs, agent2, agent3);
            }
            return(result);
        }
Esempio n. 8
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool flag = false;

            if (opl != null)
            {
                Agent agentL = pAgent;
                if (opl.GetParentType() == ParentType.PT_INSTANCE)
                {
                    agentL = Agent.GetInstance(opl.GetInstanceNameString(), agentL.GetContextId());
                }
                Agent instance = pAgent;
                if (opr.GetParentType() == ParentType.PT_INSTANCE)
                {
                    instance = Agent.GetInstance(opr.GetInstanceNameString(), agentL.GetContextId());
                }
                return(comparator.Execute(agentL, instance));
            }
            if (opl_m == null)
            {
                return(flag);
            }
            ParentType parentType = opl_m.GetParentType();
            Agent      parent     = pAgent;

            if (parentType == ParentType.PT_INSTANCE)
            {
                parent = Agent.GetInstance(opl_m.GetInstanceNameString(), parent.GetContextId());
            }
            object lhs    = opl_m.run(parent, pAgent);
            Agent  agentR = pAgent;

            if (opr.GetParentType() == ParentType.PT_INSTANCE)
            {
                agentR = Agent.GetInstance(opr.GetInstanceNameString(), agentR.GetContextId());
            }
            return(comparator.Execute(lhs, parent, agentR));
        }
Esempio n. 9
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr, CMethodBase opr_m)
        {
            bool bResult = false;

            if (opl != null)
            {
                Agent agent_left  = opl.GetParentAgent(pAgent);
                Agent agent_right = opr != null?opr.GetParentAgent(pAgent) : opr_m.GetParentAgent(pAgent);

                bResult = comparator.Execute(agent_left, agent_right);
            }
            else if (opl_m != null)
            {
                Agent agent_left = opl_m.GetParentAgent(pAgent);

                object returnValue = opl_m.Invoke(agent_left, pAgent);

                Agent agent_right = opr != null?opr.GetParentAgent(pAgent) : opr_m.GetParentAgent(pAgent);

                bResult = comparator.Execute(returnValue, agent_left, agent_right);
            }

            return(bResult);
        }
Esempio n. 10
0
 private VariableComparator(VariableComparator copy)
 {
     this.m_lhs = copy.m_lhs;
     this.m_rhs = copy.m_rhs;
 }
Esempio n. 11
0
            public virtual bool load(List <property_t> properties)
            {
                string opr2TypeName   = null;
                string comparatorName = null;

                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];
                    if (p.name == "Mode")
                    {
                        switch (p.value)
                        {
                        case "Condition":
                            this.m_mode = TransitionMode.Condition;
                            break;

                        case "Success":
                            this.m_mode = TransitionMode.Success;
                            break;

                        case "Failure":
                            this.m_mode = TransitionMode.Failure;
                            break;

                        case "End":
                            this.m_mode = TransitionMode.End;
                            break;
                        }
                    }
                    else if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                string typeName = null;
                                this.m_opl = Condition.LoadRight(p.value, ref typeName);
                            }
                            else
                            {
                                //method
                                this.m_opl_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                string typeName = null;
                                this.m_opr1 = Condition.LoadRight(p.value, ref typeName);
                            }
                            else
                            {
                                //method
                                this.m_opr1_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        comparatorName = p.value;

                        switch (p.value)
                        {
                        case "Invalid":
                            this.m_operator = EOperatorType.E_INVALID;
                            break;

                        case "Assign":
                            this.m_operator = EOperatorType.E_ASSIGN;
                            break;

                        case "Add":
                            this.m_operator = EOperatorType.E_ADD;
                            break;

                        case "Sub":
                            this.m_operator = EOperatorType.E_SUB;
                            break;

                        case "Mul":
                            this.m_operator = EOperatorType.E_MUL;
                            break;

                        case "Div":
                            this.m_operator = EOperatorType.E_DIV;
                            break;

                        case "Equal":
                            this.m_operator = EOperatorType.E_EQUAL;
                            break;

                        case "NotEqual":
                            this.m_operator = EOperatorType.E_NOTEQUAL;
                            break;

                        case "Greater":
                            this.m_operator = EOperatorType.E_GREATER;
                            break;

                        case "Less":
                            this.m_operator = EOperatorType.E_LESS;
                            break;

                        case "GreaterEqual":
                            this.m_operator = EOperatorType.E_GREATEREQUAL;
                            break;

                        case "LessEqual":
                            this.m_operator = EOperatorType.E_LESSEQUAL;
                            break;
                        }
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = Condition.LoadRight(p.value, ref opr2TypeName);
                            }
                            else
                            {
                                //method
                                this.m_opr2_m = Action.LoadMethod(p.value);
                            }
                        }
                    }
                    else
                    {
                        //Debug.Check(0, "unrecognised property %s", p.name);
                    }
                }

                // compare
                if (this.m_operator >= EOperatorType.E_EQUAL && this.m_operator <= EOperatorType.E_LESSEQUAL)
                {
                    if (!string.IsNullOrEmpty(comparatorName) && (this.m_opl != null || this.m_opl_m != null) &&
                        (this.m_opr2 != null || this.m_opr2_m != null))
                    {
                        this.m_comparator = Condition.Create(comparatorName, this.m_opl, this.m_opl_m, this.m_opr2, this.m_opr2_m);
                    }
                }

                return(this.m_opl != null);
            }