Beispiel #1
0
        /// <summary>
        /// Processes the segment.
        /// Loops through all of the fields within the segment, and parsing them individually.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentNode">The parent node.</param>
        private static void ProcessSegmentNew(AbstractSegment segment, FieldGroup parentNode)
        {
            FieldGroup segmentNode = new FieldGroup()
            {
                Name = segment.GetStructureName(), Id = segment.GetStructureName()
            };
            int dataItemCount = 0;

            for (int i = 1; i <= segment.NumFields(); i++)
            {
                dataItemCount++;
                IType[] dataItems = segment.GetField(i);
                foreach (IType item in dataItems)
                {
                    ProcessFieldNew(item, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }

                if (dataItems.Count() == 0 && segmentNode.FieldList.Count > 0)
                {
                    AbstractPrimitive msg = null;
                    ProcessPrimitiveFieldNew((AbstractPrimitive)msg, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }
            }

            AddChildGroupNew(parentNode, segmentNode);
        }
Beispiel #2
0
        /// <summary>
        /// Processes the segment.
        /// Loops through all of the fields within the segment, and parsing them individually.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentNode">The parent node.</param>
        private static void ProcessSegment(AbstractSegment segment, FieldGroup parentNode)
        {
            FieldGroup segmentNode = new FieldGroup()
            {
                Name = segment.GetStructureName(), Id = segment.GetStructureName()
            };
            int dataItemCount = 0;

            for (int i = 1; i <= segment.NumFields(); i++)
            {
                dataItemCount++;
                IType[] dataItems = segment.GetField(i);
                foreach (IType item in dataItems)
                {
                    ProcessField(item, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }
            }

            AddChildGroup(parentNode, segmentNode);
        }
        //loop through each segment
        private void LoopOnSegments(IStructure[] structures)
        {
            //Structure could be segment or a group
            foreach (IStructure structure in structures)
            {
                AbstractSegment segment = structure as AbstractSegment;
                if (segment == null)
                {
                    AbstractGroup grp = structure as AbstractGroup;
                    foreach (string name in grp.Names)
                    {
                        LoopOnSegments(grp.GetAll(name));
                    }
                }
                else
                {
                    currentSegment = segment.GetStructureName();
                    IEnumerable <CSegment> csegs = segments.Where(cseg => cseg.Name.Equals(currentSegment));
                    if (csegs.Count() > 0)
                    {
                        csegs.First().Sequence += 1;
                    }
                    else
                    {
                        segments.Add(new CSegment()
                        {
                            Name = currentSegment, Sequence = 1
                        });
                    }

                    for (int i = 1; i <= segment.NumFields(); i++)
                    {
                        fieldNumber = i;
                        LoopOnFields(segment.GetField(i));
                    }
                }
            }
        }