/// <summary> Fills a field with values from an unparsed string representing the field. </summary> /// <param name="destinationField">the field Type /// </param> /// <param name="data">the field string (including all components and subcomponents; not including field delimiters) /// </param> /// <param name="encodingCharacters">the encoding characters used in the message /// </param> private static void Parse(IType destinationField, String data, EncodingCharacters encodingCharacters) { String[] components = Split(data, Convert.ToString(encodingCharacters.ComponentSeparator)); for (int i = 0; i < components.Length; i++) { int index = i + 1; if (components[i] != null && (Terser.isPrimitive(destinationField, index) && components[i].Contains(Convert.ToString(encodingCharacters.SubcomponentSeparator)))) { // sometimes someone sends us bad data and if the destinition is a primitive we should escape what needs to be escaped components[i] = Escape.escape(components[i], encodingCharacters); } String[] subcomponents = Split(components[i], Convert.ToString(encodingCharacters.SubcomponentSeparator)); for (int j = 0; j < subcomponents.Length; j++) { String val = subcomponents[j]; if (val != null) { val = Escape.unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, index, j + 1).Value = val; } } }