public int?Map(GradingStyleEnum styleEnum, int?value) { if (!value.HasValue) { return(null); } if (value < 0) { throw new ChalkableException(string.Format(ChlkResources.ERR_GRADING_STYLE_INVALID_GRADE_VALUE, value)); } if (styleEnum == GradingStyleEnum.Numeric100) { if (value.Value > 100) { throw new ChalkableException(string.Format(ChlkResources.ERR_GRADING_STYLE_INVALID_GRADE_VALUE, value)); } return(value); } IList <int> mapping = mappers[styleEnum]; int i; for (i = 0; i < mapping.Count; i++) { if (value <= mapping[i]) { break; } } if (i == mapping.Count) { if (value < 0) { throw new ChalkableException(string.Format(ChlkResources.ERR_GRADING_STYLE_INVALID_GRADE_VALUE, value)); } } return(i); }
public int?MapBack(GradingStyleEnum styleEnum, int?styledValue) { if (!styledValue.HasValue) { return(null); } if (styledValue < 0) { throw new ChalkableException(string.Format(ChlkResources.ERR_GRADING_STYLE_INVALID_GRADE_VALUE, styledValue)); } if (styleEnum == GradingStyleEnum.Numeric100) { return(styledValue); } IList <int> mapping = mappers[styleEnum]; if (styledValue.Value >= mapping.Count) { throw new ChalkableException(string.Format(ChlkResources.ERR_GRADING_STYLE_INVALID_GRADE_VALUE, styledValue)); } return(mapping[styledValue.Value]); }
public IList <int> GetValuesByStyle(GradingStyleEnum styleEnum) { return(mappers[styleEnum]); }