コード例 #1
0
ファイル: PathExpression.cs プロジェクト: tslaats/Reseda
        ISet <Event> ApplyFilter(ISet <Event> s, Event context)
        {
            if (this.filter == null)
            {
                return(s);
            }

            var result = new HashSet <Event>();

            try
            {
                var val = this.filter.Eval(context);
                if (val.GetType() == typeof(IntType))
                {
                    IntType v = (IntType)val;
                    if (s.Count > v.value)
                    {
                        result.Add(s.ElementAt(v.value));
                    }
                    return(result);
                }
            }
            catch
            { }

            foreach (var e in s)
            {
                var val = this.filter.Eval(e);
                if (val.GetType() == typeof(BoolType))
                {
                    BoolType v = (BoolType)val;
                    if (v.value)
                    {
                        result.Add(e);
                    }
                }
            }
            return(result);


            //throw new Exception("Bad filter type: " + val.GetType());
        }