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); }
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)); }
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); }
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); }