/// <summary> Creates a version-specific MSH object and returns it as a version-independent /// MSH interface. /// throws HL7Exception if there is a problem, e.g. invalid version, code not available /// for given version. /// </summary> public static Segment makeControlMSH(System.String version, NuGenModelClassFactory factory) { Segment msh = null; try { Message dummy = (Message)GenericMessage.getGenericMessageClass(version).GetConstructor(new System.Type[] { typeof(NuGenModelClassFactory) }).Invoke(new System.Object[] { factory }); System.Type[] constructorParamTypes = new System.Type[] { typeof(Group), typeof(NuGenModelClassFactory) }; System.Object[] constructorParamArgs = new System.Object[] { dummy, factory }; System.Type c = factory.getSegmentClass("MSH", version); System.Reflection.ConstructorInfo constructor = c.GetConstructor(constructorParamTypes); msh = (Segment)constructor.Invoke(constructorParamArgs); } catch (System.Exception e) { throw new NuGenHL7Exception("Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e); } return(msh); }
/// <param name="theFactory">custom factory to use for model class lookup /// </param> public NuGenParser(NuGenModelClassFactory theFactory) { myFactory = theFactory; setValidationContext(new DefaultValidation()); }
/// <summary> Uses DefaultModelClassFactory for model class lookup. </summary> public NuGenParser() { myFactory = new NuGenDefaultModelClassFactory(); setValidationContext(new DefaultValidation()); }
/// <summary> Creates a version-specific MSH object and returns it as a version-independent /// MSH interface. /// throws HL7Exception if there is a problem, e.g. invalid version, code not available /// for given version. /// </summary> public static Segment makeControlMSH(System.String version, NuGenModelClassFactory factory) { Segment msh = null; try { Message dummy = (Message) GenericMessage.getGenericMessageClass(version).GetConstructor(new System.Type[]{typeof(NuGenModelClassFactory)}).Invoke(new System.Object[]{factory}); System.Type[] constructorParamTypes = new System.Type[]{typeof(Group), typeof(NuGenModelClassFactory)}; System.Object[] constructorParamArgs = new System.Object[]{dummy, factory}; System.Type c = factory.getSegmentClass("MSH", version); System.Reflection.ConstructorInfo constructor = c.GetConstructor(constructorParamTypes); msh = (Segment) constructor.Invoke(constructorParamArgs); } catch (System.Exception e) { throw new NuGenHL7Exception("Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e); } return msh; }