コード例 #1
0
        /// <summary> Note that the validation context of the resulting message is set to this parser's validation
        /// context.  The validation context is used within Primitive.setValue().
        ///
        /// </summary>
        /// <param name="name">name of the desired structure in the form XXX_YYY
        /// </param>
        /// <param name="version">HL7 version (e.g. "2.3")
        /// </param>
        /// <param name="isExplicit">true if the structure was specified explicitly in MSH-9-3, false if it
        /// was inferred from MSH-9-1 and MSH-9-2.  If false, a lookup may be performed to find
        /// an alternate structure corresponding to that message type and event.
        /// </param>
        /// <returns> a Message instance
        /// </returns>
        /// <throws>  HL7Exception if the version is not recognized or no appropriate class can be found or the Message  </throws>
        /// <summary>      class throws an exception on instantiation (e.g. if args are not as expected)
        /// </summary>
        protected internal virtual IMessage InstantiateMessage(System.String theName, System.String theVersion, bool isExplicit)
        {
            IMessage result = null;

            System.Type messageClass = _modelClassFactory.GetMessageClass(theName, theVersion, isExplicit);
            if (messageClass == null)
            {
                throw new System.Exception("Can't find message class in current package list: " + theName);
            }
            _log.Info("Instantiating msg of class " + messageClass.FullName);
            System.Reflection.ConstructorInfo constructor = messageClass.GetConstructor(new System.Type[] { typeof(IModelClassFactory) });
            result = (IMessage)constructor.Invoke(new System.Object[] { _modelClassFactory });
            result.ValidationContext = _validationContext;
            return(result);
        }