Exemple #1
0
 // We need methods that get the IDs of the set of dependent courses of a given course.
 // These IDs will be used as input for constructing the graph relationships.
 public int GetCourseIdFromName(string courseName, ThrowErrorOnMissing throwErrorOnMissing = ThrowErrorOnMissing.Yes)
 {
     if (!CourseAlreadyAdded(courseName)) // i.e. if Course is missing from Courses.
     {
         if (throwErrorOnMissing == ThrowErrorOnMissing.Yes)
         {
             throw new NullReferenceException(courseName + " has not been added to Courses!");
         }
         return(-1);
     }
     else
     {
         return(this[courseName].ID);
     }
 }
Exemple #2
0
 public string[] GetAdjacentCourseNamesFromCourseName(string courseName, ThrowErrorOnMissing throwErrorOnMissing = ThrowErrorOnMissing.Yes)
 {
     if (!CourseAlreadyAdded(courseName)) // i.e. if Course is missing from Courses.
     {
         if (throwErrorOnMissing == ThrowErrorOnMissing.Yes)
         {
             throw new NullReferenceException(courseName + " has not been added to Courses!");
         }
         return(new string[] {});
     }
     else
     {
         if (this[courseName].HasDependencies)
         {
             return(this[courseName].GetDependentCourseNames());
         }
         return(new string[] { });
     }
 }
Exemple #3
0
 public IEnumerable <int> GetAdjacentCourseIDsFromCourseId(int courseId, ThrowErrorOnMissing throwErrorOnMissing = ThrowErrorOnMissing.Yes)
 {
     if (!CourseIndexes.ContainsKey(courseId))
     {
         if (throwErrorOnMissing == ThrowErrorOnMissing.Yes)
         {
             throw new NullReferenceException(courseId + " has not been added to Course indexes!");
         }
         return(new List <int> {
         });
     }
     else
     {
         var courseName = CourseIndexes[courseId];
         var course     = this[courseName];
         if (course.HasDependencies)
         {
             return(this[courseName].GetDependentCourseIDs(this));
         }
         return(new List <int> {
         });
     }
 }