public override void Build() { int id; int level = -1; if (Literal.Contains(",")) { var split = Literal.Split(','); if (split.Length != 2 || !int.TryParse(split[0], out id) || !int.TryParse(split[1], out level)) { throw new Exception(string.Format("Cannot build JobCriterion, {0} is not a valid job (format 'id,level')", Literal)); } } if (!int.TryParse(Literal, out id)) { throw new Exception(string.Format("Cannot build JobCriterion, {0} is not a valid job id", Literal)); } Id = id; Level = level; }