//--------------------------------------------------------------------- public InputVariableException(InputVariable var, string message, Exception exception) : base(message, exception) { Variable = var; }
//--------------------------------------------------------------------- public InputVariableException(InputVariable var, string message, params object[] args) : base(string.Format(message, args)) { Variable = var; }
//--------------------------------------------------------------------- private bool ReadVariable(InputVariable var, bool optional) { if (var == null) throw new System.ArgumentNullException(); if (VariableNameMatches(var.Name, optional)) { // Read the variable's value StringReader strReader = new StringReader(textAfterName); try { var.ReadValue(strReader); } catch (InputVariableException exc) { throw new LineReaderException(reader, exc); } TextReader.SkipWhitespace(strReader); string textAfterValue = strReader.ReadToEnd(); if (textAfterValue.Length == 0) return true; string message = string.Format("Extra text after the value for \"{0}\"", var.Name); throw ExtraTextException(message, textAfterValue); } return false; }
//--------------------------------------------------------------------- /// <summary> /// Reads the name and value for an InputVariable. /// </summary> public void ReadVar(InputVariable var) { ReadVariable(var, false); }
//--------------------------------------------------------------------- /// <summary> /// Reads the name and value for an optional InputVariable. /// </summary> public bool ReadOptionalVar(InputVariable var) { return ReadVariable(var, true); }
//--------------------------------------------------------------------- private void TryReadVar(InputLine line, InputVariable var) { try { line.ReadVar(var); } catch (System.Exception e) { Data.Output.WriteLine(e.Message); throw; } }