本文整理汇总了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);
}
}