Пример #1
0
        /// <summary>
        /// Splits a segment line into composite data elements
        /// </summary>
        /// <param name="ediSegment">The segment line</param>
        /// <param name="interchangeContext">The interchange context containing the separators</param>
        /// <returns>The collection of composite data elements</returns>
        public static string[] GetEdiCompositeDataElements(string ediSegment, InterchangeContext interchangeContext)
        {
            if (string.IsNullOrEmpty(ediSegment))
            {
                throw new ArgumentNullException("ediSegment");
            }
            if (interchangeContext == null)
            {
                throw new ArgumentNullException("interchangeContext");
            }

            // Handle escapes
            // Retains blank lines
            var result = !string.IsNullOrEmpty(interchangeContext.ReleaseIndicator)
                                      ? ediSegment.EscapeSplit(interchangeContext.ReleaseIndicator[0],
                                                               interchangeContext.DataElementSeparator[0], StringSplitOptions.None)
                                      : ediSegment.Split(interchangeContext.DataElementSeparator.ToCharArray(),
                                                         StringSplitOptions.None);

            // Skip the segment name
            return(result.Skip(1).ToArray());
        }