public void SetRuntimeValue(Report rpt, object v) { if (this.MultiValue) { // ok to only set one parameter of multiValue; but we still save as MultiValue ArrayList ar; if (v is string) { // when the value is a string we parse it looking for multiple arguments ParameterLexer pl = new ParameterLexer(v as string); ar = pl.Lex(); } else if (v is ICollection) { // when collection put it in local array ar = new ArrayList(v as ICollection); } else { ar = new ArrayList(1); ar.Add(v); } SetRuntimeValues(rpt, ar); return; } object rtv; if (!AllowBlank && _dt == TypeCode.String && (string)v == "") { throw new ArgumentException(string.Format("Empty string isn't allowed for {0}.", Name.Nm)); } try { if (v is String && _NumericType) { v = ConvertStringToNumber((string)v); } rtv = Convert.ChangeType(v, _dt); } catch (Exception e) { // illegal parameter passed string err = "Illegal parameter value for '" + Name.Nm + "' provided. Value =" + v.ToString(); if (rpt == null) { OwnerReport.rl.LogError(4, err); } else { rpt.rl.LogError(4, err); } throw new ArgumentException(string.Format("Unable to convert '{0}' to {1} for {2}", v, _dt, Name.Nm), e); } rpt.Cache.AddReplace(this, "runtimevalue", rtv); }
/// <summary> /// Take a string and parse it into multiple values /// </summary> /// <param name="v"></param> /// <returns></returns> private ArrayList ParseValue(string v) { ParameterLexer pl = new ParameterLexer(v); return pl.Lex(); }
public void SetRuntimeValue(Report rpt, object v) { if (this.MultiValue) { // ok to only set one parameter of multiValue; but we still save as MultiValue ArrayList ar; if (v is string) { // when the value is a string we parse it looking for multiple arguments ParameterLexer pl = new ParameterLexer(v as string); ar = pl.Lex(); } else if (v is ICollection) { // when collection put it in local array ar = new ArrayList(v as ICollection); } else { ar = new ArrayList(1); ar.Add(v); } SetRuntimeValues(rpt, ar); return; } object rtv; if (!AllowBlank && _dt == TypeCode.String && (string) v == "") throw new ArgumentException(string.Format("Empty string isn't allowed for {0}.", Name.Nm)); try { if (v is String && _NumericType) v = ConvertStringToNumber((string) v); rtv = Convert.ChangeType(v, _dt); } catch (Exception e) { // illegal parameter passed string err = "Illegal parameter value for '" + Name.Nm + "' provided. Value =" + v.ToString(); if (rpt == null) OwnerReport.rl.LogError(4, err); else rpt.rl.LogError(4, err); throw new ArgumentException(string.Format("Unable to convert '{0}' to {1} for {2}", v, _dt, Name.Nm),e); } rpt.Cache.AddReplace(this, "runtimevalue", rtv); }
/// <summary> /// Take a string and parse it into multiple values /// </summary> /// <param name="v"></param> /// <returns></returns> private ArrayList ParseValue(string v) { ParameterLexer pl = new ParameterLexer(v); return(pl.Lex()); }