void AssignUniqueIds(Exercise content, ref int cnt) { if (content is EvalExercise) ((EvalExercise)content).Id = cnt++; foreach (Exercise ex in content.SubExercises) AssignUniqueIds(ex, ref cnt); }
void AssignOwners(Exercise ex, Exercise owner) { ex.Owner = owner; ex.Expand(); foreach (Exercise subex in ex.SubExercises) AssignOwners(subex, ex); }
protected static IEnumerable<Exercise> getSubExcs(Exercise[] excs) { return excs == null ? Enumerable.Empty<Exercise>() : excs; }
protected static Exercise[] expandHelper(Exercise[] excs) { if (excs == null || !excs.Any(e => e is IExpandable)) return excs; List<Exercise> res = new List<Exercise>(); foreach (Exercise ex in excs) if (ex is IExpandable) res.AddRange(((IExpandable)ex).Expand()); else res.Add(ex); return res.ToArray(); }
public static Exercise expandHelper(Exercise by) { if (by == null || !(by is IExpandable)) return by; return ((IExpandable)by).Expand().SingleOrDefault(); }