本文整理汇总了C#中IModelClassFactory.GetTypeClass方法的典型用法代码示例。如果您正苦于以下问题:C# IModelClassFactory.GetTypeClass方法的具体用法?C# IModelClassFactory.GetTypeClass怎么用?C# IModelClassFactory.GetTypeClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModelClassFactory
的用法示例。
在下文中一共展示了IModelClassFactory.GetTypeClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fixOBX5
/// <summary> Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument
/// is a Segment as opposed to a particular OBX because it is meant to work with any version.
/// </summary>
public static void fixOBX5(ISegment segment, IModelClassFactory factory)
{
try
{
//get unqualified class name
IPrimitive obx2 = (IPrimitive) segment.GetField(2, 0);
foreach (IType repetition in segment.GetField(5))
{
Varies v = (Varies) repetition;
if (obx2.Value == null)
{
if (v.Data != null)
{
if (!(v.Data is IPrimitive) || ((IPrimitive) v.Data).Value != null)
{
throw new HL7Exception(
"OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.",
HL7Exception.REQUIRED_FIELD_MISSING);
}
}
}
else
{
Type c = factory.GetTypeClass(obx2.Value, segment.Message.Version);
v.Data = (IType) c.GetConstructor(new [] {typeof (IMessage), typeof(String)}).Invoke(new Object[] {v.Message, v.Description});
}
}
}
catch (HL7Exception e)
{
throw e;
}
catch (Exception e)
{
throw new HL7Exception(e.GetType().FullName + " trying to set data type of OBX-5",
HL7Exception.APPLICATION_INTERNAL_ERROR, e);
}
}
示例2: fixOBX5
/// <summary> Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument
/// is a Segment as opposed to a particular OBX because it is meant to work with any version.
/// </summary>
public static void fixOBX5(ISegment segment, IModelClassFactory factory)
{
try
{
//get unqualified class name
IPrimitive obx2 = (IPrimitive)segment.GetField(2, 0);
Varies v = (Varies)segment.GetField(5, 0);
if (obx2.Value == null)
{
if (v.Data != null)
{
if (!(v.Data is IPrimitive) || ((IPrimitive)v.Data).Value != null)
{
throw new HL7Exception("OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.", HL7Exception.REQUIRED_FIELD_MISSING);
}
}
}
else
{
//set class
System.Type c = factory.GetTypeClass(obx2.Value, segment.Message.Version);
// Class c = NHapi.Base.Parser.ParserBase.findClass(obx2.getValue(),
// segment.getMessage().getVersion(),
// "datatype");
v.Data = (IType)c.GetConstructor(new System.Type[] { typeof(IMessage) }).Invoke(new System.Object[] { v.Message });
}
}
catch (HL7Exception e)
{
throw e;
}
catch (System.Exception e)
{
throw new HL7Exception(e.GetType().FullName + " trying to set data type of OBX-5", HL7Exception.APPLICATION_INTERNAL_ERROR, e);
}
}