示例#1
0
 public virtual void TestRegistered()
 {
     Assert.IsNotNull(ParserRegistry.GetInstance().Get("IVL<TS>"), "parser");
 }
示例#2
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        private void WriteAttribute(BeanWrapper bean, Hl7Source source, IList <XmlNode> nodes, Relationship relationship, string traversalName
                                    )
        {
            if (relationship.Structural)
            {
                source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "Data found for relationship as an element but should have been an attribute. "
                                                            + (nodes.IsEmpty() ? ("(" + relationship.Name + ")") : XmlDescriber.DescribePath(nodes[0])), CollUtils.IsEmpty(nodes) ?
                                                            null : (XmlElement)nodes[0]));
            }
            string        type   = DetermineType(nodes, relationship, source, source.GetResult());
            ElementParser parser = (source.IsR2() ? ParserR2Registry.GetInstance().Get(type) : ParserRegistry.GetInstance().Get(type)
                                    );

            if (parser != null)
            {
                try
                {
                    ConstrainedDatatype constraints = source.GetService().GetConstraints(source.GetVersion(), relationship.ConstrainedType);
                    ParseContextImpl    context     = new ParseContextImpl(relationship, constraints, source.GetVersion(), source.GetDateTimeZone(),
                                                                           source.GetDateTimeTimeZone(), CodeTypeRegistry.GetInstance(), source.IsCda());
                    BareANY @object = parser.Parse(context, nodes, source.GetResult());
                    ChangeDatatypeIfNecessary(type, relationship, @object);
                    if (relationship.HasFixedValue())
                    {
                        ValidateNonstructuralFixedValue(relationship, @object, source, nodes);
                    }
                    else
                    {
                        // fixed means nothing to write to bean
                        bean.Write(relationship, @object);
                    }
                }
                catch (InvalidCastException e)
                {
                    source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "Can't parse relationship name=" + relationship.
                                                                Name + ", traversalName=" + traversalName + " [" + e.Message + "]", CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[
                                                                    0]));
                }
            }
            else
            {
                source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "No parser for type \"" + type + "\". " + (nodes
                                                                                                                                    .IsEmpty() ? ("(" + relationship.Name + ")") : XmlDescriber.DescribePath(nodes[0])), CollUtils.IsEmpty(nodes) ? null : (
                                                                XmlElement)nodes[0]));
            }
        }