/// <summary> /// Read named parameters for a Parameterized object /// </summary> /// <param name="obj">The parameterized object</param> /// <param name="parameters">The parameters</param> /// <param name="start">The starting index</param> public static void ReadParameters(this Netlist netlist, IParameterized obj, List <Token> parameters, int start = 0) { for (int i = start; i < parameters.Count; i++) { if (parameters[i].kind == TokenConstants.ASSIGNMENT) { AssignmentToken at = parameters[i] as AssignmentToken; string pname; if (at.Name.kind == WORD) { pname = at.Name.image.ToLower(); } else { throw new ParseException(parameters[i], "Invalid assignment"); } switch (at.Value.kind) { case VALUE: obj.Set(pname, netlist.Readers.ParseDouble(at.Value.image.ToLower())); break; case EXPRESSION: obj.Set(pname, netlist.Readers.ParseDouble(at.Value.image.Substring(1, at.Value.image.Length - 2).ToLower())); break; case WORD: case STRING: obj.Set(pname, netlist.ParseString(at.Value)); break; default: throw new ParseException(parameters[i], "Invalid assignment"); } } } }