/// <summary> /// Splits a comma delimited GIMIC value into a list of string values /// </summary> /// <param name="tokenState"></param> /// <param name="value"></param> /// <returns></returns> public static dynamic CreateListOfValues(this TokenState tokenState, dynamic value) { var list = new List <string>(); var chunked = value.Split(','); foreach (var chunk in chunked) { list.Add(tokenState.ReInsertCapturedTokens((string)chunk)); } value = list; return(value); }
/// <summary> /// Parses the value from a line of GIMIC text /// </summary> /// <param name="line"></param> /// <param name="sr"></param> /// <param name="map"></param> public static void ParseValue(this Line line, StreamReader sr, IMap <string, dynamic> map) { if (line is null || sr is null || map is null) { return; } var tokenState = new TokenState(); dynamic value = sr.CaptureAndEscapeTokens((string)line.Value, ref tokenState); value = value.Contains(',') ? tokenState.CreateListOfValues((string)value) : tokenState.ReInsertCapturedTokens((string)value); map.Add(line.Key, value); }