Esempio n. 1
0
        public override int IndexOf(object a)
        {
            if (a is FunctionInstance)
            {
                var func = (FunctionInstance)a;

                for (int i = 0; i < this.Count; i++)
                {
                    var    rule = new FloodRule(script, this.rules[i]);
                    object ret  = func.Call(Engine.Global, rule);

                    if (TypeConverter.ConvertTo <bool>(Engine, ret))
                    {
                        return(i);
                    }
                }
                return(-1);
            }
            else if (a is FloodRule)
            {
                var rule = (FloodRule)a;
                return(this.rules.FindIndex((s) => s.Id == rule.Id));
            }

            return(-1);
        }
Esempio n. 2
0
        public override PropertyDescriptor GetOwnPropertyDescriptor(uint index)
        {
            if (index < Count)
            {
                var rule = new FloodRule(script, this.rules[(int)index]);
                return(new PropertyDescriptor(rule, PropertyAttributes.FullAccess));
            }

            return(new PropertyDescriptor(null, PropertyAttributes.Sealed));
        }
Esempio n. 3
0
        public override object Find(object a)
        {
            if (a is FunctionInstance func)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    var    rule = new FloodRule(script, this.rules[i]);
                    object ret  = func.Call(Engine.Global, rule);

                    if (TypeConverter.ConvertTo <bool>(Engine, ret))
                    {
                        return(rule);
                    }
                }
            }

            return(null);
        }
Esempio n. 4
0
        public override Collection FindAll(object a)
        {
            if (a is FunctionInstance func)
            {
                var list = new List(script);

                for (int i = 0; i < this.Count; i++)
                {
                    var    rule = new FloodRule(script, this.rules[i]);
                    object ret  = func.Call(Engine.Global, rule);

                    if (TypeConverter.ConvertTo <bool>(Engine, ret))
                    {
                        list.Add(rule);
                    }
                }

                return(list);
            }

            return(null);
        }