private static object FuncFilter(object[] args) { if (!_mnr.CheckArgCount(2, "filter", args)) { return(null); } object list = args[0]; string property; property = args[1].ToString(); if (!(list is IEnumerable)) { throw new VoltException("argument 1 of filter has to be IEnumerable", 0, 0); } IEnumerator ienum = ((IEnumerable)list).GetEnumerator(); List <object> newList = new List <object>(); while (ienum.MoveNext()) { object val = VoltEngine.ProcessProperty(ienum.Current, property); if (val is bool && (bool)val) { newList.Add(ienum.Current); } } return(newList); }
private static object FuncJoin(object[] args) { if (!_mnr.CheckArgCount(2, 3, "join", args)) { return(null); } object list = args[0]; string property; string delim; if (args.Length == 3) { property = args[1].ToString(); delim = args[2].ToString(); } else { property = string.Empty; delim = args[1].ToString(); } if (!(list is IEnumerable)) { throw new VoltException("argument 1 of join has to be IEnumerable", 0, 0); } IEnumerator ienum = ((IEnumerable)list).GetEnumerator(); StringBuilder sb = new StringBuilder(); int index = 0; while (ienum.MoveNext()) { if (index > 0) { sb.Append(delim); } if (args.Length == 2) // do not evalulate property { sb.Append(ienum.Current); } else { sb.Append(VoltEngine.ProcessProperty(ienum.Current, property)); } index++; } return(sb.ToString()); }