当前位置: 首页>>代码示例>>C#>>正文


C# ISegment.GetMaxCardinality方法代码示例

本文整理汇总了C#中ISegment.GetMaxCardinality方法的典型用法代码示例。如果您正苦于以下问题:C# ISegment.GetMaxCardinality方法的具体用法?C# ISegment.GetMaxCardinality怎么用?C# ISegment.GetMaxCardinality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISegment的用法示例。


在下文中一共展示了ISegment.GetMaxCardinality方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary> Parses a segment string and populates the given Segment object.  Unexpected fields are
        /// added as Varies' at the end of the segment.  
        /// 
        /// </summary>
        /// <throws>  HL7Exception if the given string does not contain the </throws>
        /// <summary>      given segment or if the string is not encoded properly
        /// </summary>
        public virtual void Parse(ISegment destination, String segment, EncodingCharacters encodingChars)
        {
            int fieldOffset = 0;
            if (IsDelimDefSegment(destination.GetStructureName()))
            {
                fieldOffset = 1;
                //set field 1 to fourth character of string
                Terser.Set(destination, 1, 0, 1, 1, Convert.ToString(encodingChars.FieldSeparator));
            }

            String[] fields = Split(segment, Convert.ToString(encodingChars.FieldSeparator));

            for (int i = 1; i < fields.Length; i++)
            {
                String[] reps = Split(fields[i], Convert.ToString(encodingChars.RepetitionSeparator));
                if (log.DebugEnabled)
                {
                    log.Debug(reps.Length + "reps delimited by: " + encodingChars.RepetitionSeparator);
                }

                //MSH-2 will get split incorrectly so we have to fudge it ...
                bool isMSH2 = IsDelimDefSegment(destination.GetStructureName()) && i + fieldOffset == 2;
                if (isMSH2)
                {
                    reps = new String[1];
                    reps[0] = fields[i];
                }

                for (int j = 0; j < reps.Length; j++)
                {
                    try
                    {
                        StringBuilder statusMessage = new StringBuilder("Parsing field ");
                        statusMessage.Append(i + fieldOffset);
                        statusMessage.Append(" repetition ");
                        statusMessage.Append(j);
                        log.Debug(statusMessage.ToString());

                        if (i > 0 && i <= destination.NumFields() && j < destination.GetMaxCardinality(i))
                        {
                            IType field = destination.GetField(i + fieldOffset, j);
                            if (isMSH2)
                            {
                                Terser.getPrimitive(field, 1, 1).Value = reps[j];
                            }
                            else
                            {
                                Parse(field, reps[j], encodingChars);
                            }
                        }
                        else
                        {
                            StringBuilder errorMessage = new StringBuilder("Unexpected repitition for field ");
                            statusMessage.Append(i + fieldOffset);
                            statusMessage.Append(" repetition ");
                            statusMessage.Append(j);
                            statusMessage.Append(", ignoring extra repititions.");
                            log.Debug(statusMessage.ToString());
                        }
                    }
                    catch (HL7Exception e)
                    {
                        //set the field location and throw again ...
                        e.FieldPosition = i + fieldOffset;
                        e.SegmentRepetition = MessageIterator.getIndex(destination.ParentStructure, destination).rep;
                        e.SegmentName = destination.GetStructureName();
                        throw;
                    }
                }
            }

            //set data type of OBX-5
            if (destination.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(destination, Factory);
            }
        }
开发者ID:Eric-Cadwell,项目名称:nHapi,代码行数:84,代码来源:PipeParser.cs


注:本文中的ISegment.GetMaxCardinality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。