PurplePen.Course.ValidateCourseControlsToJoin C# (CSharp) Method

ValidateCourseControlsToJoin() private method

private ValidateCourseControlsToJoin ( Id nextCourseControl, Id idJoin, Id idCourse, EventDB validateInfo ) : void
nextCourseControl Id
idJoin Id
idCourse Id
validateInfo EventDB
return void
        private void ValidateCourseControlsToJoin(Id<CourseControl> nextCourseControl, Id<CourseControl> idJoin, Id<Course> idCourse, EventDB.ValidateInfo validateInfo)
        {
            while (nextCourseControl.IsNotNone && nextCourseControl != idJoin) {
                CourseControl courseCtl = validateInfo.eventDB.GetCourseControl(nextCourseControl);

                if (courseCtl.split) {
                    if (kind == CourseKind.Score)
                        throw new ApplicationException("Score courses cannot have split variations");
                    if (courseCtl.splitCourseControls == null)
                        throw new ApplicationException("no variations listed for variation start control");

                    // Validate all other branches but this one.
                    for (int i = 0; i < courseCtl.splitCourseControls.Length; ++i) {
                        if (courseCtl.splitCourseControls[i] != nextCourseControl) {
                            ValidateCourseControl(courseCtl.splitCourseControls[i], idCourse, validateInfo);
                            ValidateCourseControlsToJoin(validateInfo.eventDB.GetCourseControl(courseCtl.splitCourseControls[i]).nextCourseControl,
                                                         courseCtl.splitEnd, idCourse, validateInfo);
                        }
                    }
                }

                ValidateCourseControl(nextCourseControl, idCourse, validateInfo);
                nextCourseControl = courseCtl.nextCourseControl;
            }

            if (nextCourseControl != idJoin)
                throw new ApplicationException("join control not reached");
        }