Example #1
0
        public bool Test(GameData.Item item)
        {
            object bah;
            bool   flag;

            if (this.type != itemType.NULL_ITEM && item.type != this.type)
            {
                return(false);
            }
            if (this.name != "" && !item.Name.ToLower().Contains(this.name) && !item.stringID.ToLower().Contains(this.name))
            {
                return(false);
            }
            List <ItemFilter.PropertyFilter> .Enumerator enumerator = this.property.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    ItemFilter.PropertyFilter current = enumerator.Current;
                    if (current.property == "Type")
                    {
                        bah = item.type;
                    }
                    else if (current.property == "StringID")
                    {
                        bah = item.stringID;
                    }
                    else if (item.ContainsKey(string.Concat(current.property, "0")))
                    {
                        bool flag1 = false;
                        int  num   = 0;
                        while (!flag1)
                        {
                            string str = string.Concat(current.property, num);
                            if (!item.ContainsKey(str))
                            {
                                break;
                            }
                            flag1 |= this.compareValue(item[str], current.@value, current.mode);
                            num++;
                        }
                        if (flag1)
                        {
                            continue;
                        }
                        flag = false;
                        return(flag);
                    }
                    else if (item.ContainsKey(current.property))
                    {
                        bah = item[current.property];
                        if (bah is int && current.mode <= ItemFilter.PropertyFilter.Mode.NOT)
                        {
                            GameData.Desc desc = GameData.getDesc(item.type, current.property);
                            if (desc != GameData.nullDesc)
                            {
                                Type type = desc.defaultValue.GetType();
                                if (type.IsEnum)
                                {
                                    bah = Enum.GetName(type, bah);
                                }
                                if (bah == null)
                                {
                                    flag = false;
                                    return(flag);
                                }
                            }
                        }
                    }
                    else if (!item.hasReference(current.property))
                    {
                        GameData.Desc desc1 = GameData.getDesc(item.type, current.property);
                        if (desc1 == null || desc1.list == itemType.NULL_ITEM)
                        {
                            flag = false;
                            return(flag);
                        }
                        else
                        {
                            bah = 0;
                        }
                    }
                    else
                    {
                        bah = item.getReferenceCount(current.property);
                    }
                    if (this.compareValue(bah, current.@value, current.mode))
                    {
                        continue;
                    }
                    flag = false;
                    return(flag);
                }
                return(true);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }

            return(flag);
        }
Example #2
0
        private void parseFilterString(string filter)
        {
            float single;

            string[] strArrays  = new string[] { "==", ">=", "<=", "!=", "!", "=", ":", ">", "<" };
            int[]    numArray   = new int[] { 0, 5, 6, 2, 2, 0, 1, 3, 4 };
            string[] strArrays1 = filter.Split(new char[] { ';' });
            for (int i = 0; i < (int)strArrays1.Length; i++)
            {
                string str = strArrays1[i];
                if (str.Trim() != "")
                {
                    string[] strArrays2 = str.Split(strArrays, 2, StringSplitOptions.RemoveEmptyEntries);
                    int      num        = -1;
                    if ((int)strArrays2.Length > 1)
                    {
                        string str1 = str.Substring(strArrays2[0].Length, 2);
                        int    num1 = 0;
                        while (num1 < (int)strArrays.Length)
                        {
                            if (!str1.StartsWith(strArrays[num1]))
                            {
                                num1++;
                            }
                            else
                            {
                                num = numArray[num1];
                                break;
                            }
                        }
                    }
                    if (num < 0)
                    {
                        this.name = str.Trim().ToLower();
                    }
                    else if ((int)strArrays2.Length >= 2)
                    {
                        ItemFilter.PropertyFilter propertyFilter = new ItemFilter.PropertyFilter()
                        {
                            mode     = (ItemFilter.PropertyFilter.Mode)num,
                            property = strArrays2[0].Trim()
                        };
                        string lower = strArrays2[1].Trim().ToLower();
                        if (num >= 3)
                        {
                            if (!float.TryParse(lower, out single))
                            {
                                //  goto Label0;
                                if (single != 0)
                                {
                                }
                            }
                            propertyFilter.@value = single;
                        }
                        else
                        {
                            propertyFilter.@value = lower;
                        }
                        this.property.Add(propertyFilter);
                    }
                }
                // Label0:
            }
        }