本文整理汇总了C#中ISegment.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ISegment.GetType方法的具体用法?C# ISegment.GetType怎么用?C# ISegment.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISegment
的用法示例。
在下文中一共展示了ISegment.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populate
/// <summary> Populates the given error segment with information from this Exception.</summary>
public virtual void populate(ISegment errorSegment)
{
//make sure it's an ERR
if (!errorSegment.GetStructureName().Equals("ERR"))
throw new HL7Exception("Can only populate an ERR segment with an exception -- got: " + errorSegment.GetType().FullName);
int rep = errorSegment.GetField(1).Length; //append after existing reps
if (this.SegmentName != null)
Terser.Set(errorSegment, 1, rep, 1, 1, this.SegmentName);
if (this.SegmentRepetition >= 0)
Terser.Set(errorSegment, 1, rep, 2, 1, System.Convert.ToString(this.SegmentRepetition));
if (this.FieldPosition >= 0)
Terser.Set(errorSegment, 1, rep, 3, 1, System.Convert.ToString(this.FieldPosition));
Terser.Set(errorSegment, 1, rep, 4, 1, System.Convert.ToString(this.errCode));
Terser.Set(errorSegment, 1, rep, 4, 3, "hl70357");
Terser.Set(errorSegment, 1, rep, 4, 5, this.Message);
//try to get error condition text
try
{
System.String desc = TableRepository.Instance.getDescription(357, System.Convert.ToString(this.errCode));
Terser.Set(errorSegment, 1, rep, 4, 2, desc);
}
catch (LookupException e)
{
ourLog.Debug("Warning: LookupException getting error condition text (are we connected to a TableRepository?)", e);
}
}
示例2: 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());
IType field = destination.GetField(i + fieldOffset, j);
if (isMSH2)
{
Terser.getPrimitive(field, 1, 1).Value = reps[j];
}
else
{
Parse(field, reps[j], encodingChars);
}
}
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);
}
}
示例3: Parse
/// <summary> Populates the given Segment object with data from the given XML Element.</summary>
/// <throws> HL7Exception if the XML Element does not have the correct name and structure </throws>
/// <summary> for the given Segment, or if there is an error while setting individual field values.
/// </summary>
public virtual void Parse(ISegment segmentObject, XmlElement segmentElement)
{
SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();
// for (int i = 1; i <= segmentObject.NumFields(); i++) {
// String elementName = makeElementName(segmentObject, i);
// done.add(elementName);
// parseReps(segmentObject, segmentElement, elementName, i);
// }
XmlNodeList all = segmentElement.ChildNodes;
for (int i = 0; i < all.Count; i++)
{
String elementName = all.Item(i).Name;
if (Convert.ToInt16(all.Item(i).NodeType) == (short) XmlNodeType.Element && !done.Contains(elementName))
{
done.Add(elementName);
int index = elementName.IndexOf('.');
if (index >= 0 && elementName.Length > index)
{
//properly formatted element
String fieldNumString = elementName.Substring(index + 1);
int fieldNum = Int32.Parse(fieldNumString);
ParseReps(segmentObject, segmentElement, elementName, fieldNum);
}
else
{
log.Debug("Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: " + elementName);
}
}
}
//set data type of OBX-5
if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
{
Varies.fixOBX5(segmentObject, Factory);
}
}