Пример #1
0
            /// more than ten times faster than SequenceEquals
            public static bool ListsAreEqual <T>(List <T> a, List <T> b)
            {
                // if both are null, ReferenceEquals returns true
                if (Object.ReferenceEquals(a, b))
                {
                    return(true);
                }

                if (a == null || b == null)
                {
                    return(false);
                }

                if (a.Count != b.Count)
                {
                    return(false);
                }

                //EqualityComparer<T> comparer = EqualityComparer<T>.Default;
                //return !b1.Where((t, i) => !comparer.Equals(t, b2[i])).Any();

                for (int i = 0; i < a.Count; ++i)
                {
                    T ai = a[i];
                    T bi = b[i];

                    bool bEqual = OperationUtils.Compare(ai, bi, EOperatorType.E_EQUAL);
                    if (!bEqual)
                    {
                        return(false);
                    }
                }

                return(true);
            }
Пример #2
0
        protected override void load(int version, string agentType, List <property_t> properties)
        {
            base.load(version, agentType, properties);

            for (int i = 0; i < properties.Count; ++i)
            {
                property_t p = properties[i];

                if (p.name == "Opl")
                {
                    this.m_opl = AgentMeta.ParseProperty(p.value);
                }
                else if (p.name == "Operator")
                {
                    Debug.Check(p.value == "Add" || p.value == "Sub" || p.value == "Mul" || p.value == "Div");

                    this.m_operator = OperationUtils.ParseOperatorType(p.value);
                }
                else if (p.name == "Opr1")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr1 = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr1 = AgentMeta.ParseMethod(p.value);
                    }
                }
                else if (p.name == "Opr2")
                {
                    int pParenthesis = p.value.IndexOf('(');

                    if (pParenthesis == -1)
                    {
                        this.m_opr2 = AgentMeta.ParseProperty(p.value);
                    }
                    else
                    {
                        this.m_opr2 = AgentMeta.ParseMethod(p.value);
                    }
                }
            }
        }
Пример #3
0
            public virtual bool load(List <property_t> properties)
            {
                for (int i = 0; i < properties.Count; ++i)
                {
                    property_t p = properties[i];

                    if (p.name == "Opl")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
Пример #4
0
            public virtual bool load(List <property_t> properties)
            {
                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)
                            {
                                this.m_opl = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opl = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Opr1")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr1 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr1 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                    else if (p.name == "Operator")
                    {
                        this.m_operator = OperationUtils.ParseOperatorType(p.value);
                    }
                    else if (p.name == "Opr2")
                    {
                        if (StringUtils.IsValidString(p.value))
                        {
                            int pParenthesis = p.value.IndexOf('(');

                            if (pParenthesis == -1)
                            {
                                this.m_opr2 = AgentMeta.ParseProperty(p.value);
                            }
                            else
                            {
                                this.m_opr2 = AgentMeta.ParseMethod(p.value);
                            }
                        }
                    }
                }

                return(this.m_opl != null);
            }
Пример #5
0
 public static bool TypesEquals <T>(T a, T b)
 {
     return(OperationUtils.Compare(a, b, EOperatorType.E_EQUAL));
 }