Пример #1
0
        public int Compare(ItemCraft x, ItemCraft y)
        {
            ItemProperties props;
            IDictionary <string, double> stats;

            if (Cache.ContainsKey(x))
            {
                props = Cache[x].Properties;
                stats = Cache[x].Stats;
            }
            else
            {
                props = ItemParser.ParseProperties(x);
                stats = ItemParser.ParseItem(x);
                Cache.Add(x, new ItemParams()
                {
                    Properties = props, Stats = stats
                });
            }
            double?vx = ItemParser.GetValueByName(Key, x, props, stats);

            if (Cache.ContainsKey(y))
            {
                props = Cache[y].Properties;
                stats = Cache[y].Stats;
            }
            else
            {
                props = ItemParser.ParseProperties(y);
                stats = ItemParser.ParseItem(y);
                Cache.Add(y, new ItemParams()
                {
                    Properties = props, Stats = stats
                });
            }
            double?vy = ItemParser.GetValueByName(Key, y, props, stats);

            if (vx != null)
            {
                if (vy != null)
                {
                    return(vx.Value.CompareTo(vy.Value));
                }
                else
                {
                    return(1);
                }
            }
            else
            {
                if (vy != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
        }
Пример #2
0
 public static FilterResult Evaluate(ItemCraft item, FilterCondition condition)
 {
     //call ParseProperties and ParseItem here and pass the results so they don't have to be repeatedly called during evaluation
     return(condition.Evaluate(item, ItemParser.ParseProperties(item), ItemParser.ParseItem(item)));
 }