public static PipeValue Map(this PipeValue value, PipeLambda map) { CommonHelper.ConfirmNotNull(map, "map"); PipeValuePropertyEnumerator enumerator = value.GetEnumerator(); PipeValueObjectBuilder collection = new PipeValueObjectBuilder(value.IsArray); while (enumerator.MoveNext()) { collection.Add(map.Invoke(enumerator), enumerator.CurrentKey); } return(collection); }
public string MatchEvaluator(Match m) { PipeValueObjectBuilder collection = new PipeValueObjectBuilder(false); foreach (Group group in m.Groups) { collection.Add(group.Value, collection.Count.ToString()); } collection.Add(m.Index, "index"); collection.Add(input, "input"); return((string)replacement.Invoke(collection)); }
public static PipeValue Where(this PipeValue value, PipeLambda filter) { CommonHelper.ConfirmNotNull(filter, "filter"); PipeValuePropertyEnumerator enumerator = value.GetEnumerator(); PipeValueObjectBuilder collection = new PipeValueObjectBuilder(value.IsArray); while (enumerator.MoveNext()) { if ((bool)filter.Invoke(enumerator)) { collection.Add(enumerator.CurrentValue, enumerator.CurrentKey); } } return(collection); }