private static IEnumerable <RPack> Optional(RPack pack, Func <IEnumerable <RPack>, IEnumerable <RPack> > graphSelector, short parametersStartIndex, short parametersEndIndex) { var packBox = Enumerable.Repeat(pack, 1); // as RPackInt[] ?? packs.ToArray(); bool any = false; foreach (var rPackInt in graphSelector(packBox)) { yield return(rPackInt); if (!any) { any = true; } } if (!any) { yield return(pack.ResetDiapason(parametersStartIndex, parametersEndIndex)); } }
private static IEnumerable <RPack> UnionRun(RPack pack, Func <IEnumerable <RPack>, IEnumerable <RPack> > first, Func <IEnumerable <RPack>, IEnumerable <RPack> > second) { var rPackIntBox = Enumerable.Repeat(pack, 1); if (first != null) { foreach (var resultRPackInt in first(rPackIntBox)) { yield return(resultRPackInt); } } if (second == null) { yield break; } foreach (var resultRPackInt in second(rPackIntBox)) { yield return(resultRPackInt); } }