コード例 #1
0
        // this case shouldn't happen, but is useful when the code is
        // translated
        /// <exception cref="System.Exception"></exception>
        private void AssertFormatterIsRegistered(Type classObj)
        {
            IList <string> keys = FormatterRegistry.GetInstance().GetRegistrationKey(classObj);

            foreach (string @string in keys)
            {
                Assert.IsNotNull(FormatterRegistry.GetInstance().Get(@string), "register " + classObj.FullName + " (" + @string + ")");
            }
        }
コード例 #2
0
        protected virtual string CreateElement(FormatContext context, string name, QTY <T> value, int indentLevel)
        {
            string            type      = Hl7DataTypeName.GetParameterizedType(context.Type);
            PropertyFormatter formatter = FormatterRegistry.GetInstance().Get(type);

            if (formatter != null)
            {
                bool isSpecializationType = false;
                return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, isSpecializationType
                                                                                                                  , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, Cardinality.Create("1"), name, context), value, indentLevel));
            }
            else
            {
                throw new ModelToXmlTransformationException("No formatter found for " + type);
            }
        }
コード例 #3
0
        public virtual void TestAllFormattersWithNullValue()
        {
            IDictionary <string, PropertyFormatter> formatters = FormatterRegistry.GetInstance().GetProtectedRegistryMap();

            foreach (string key in formatters.Keys)
            {
                PropertyFormatter formatter = formatters.SafeGet(key);
                FormatContext     context   = GetContext("name", key);
                try
                {
                    formatter.Format(context, null);
                    formatter.Format(context, null, 0);
                }
                catch (Exception e)
                {
                    Assert.Fail(key + " (" + formatter.GetType().Name + "): formatter failed when given a null value: " + e.Message);
                }
            }
        }
コード例 #4
0
 protected virtual string CreateWidthElement(FormatContext context, string name, BareDiff diff, int indentLevel)
 {
     if (IsTimestamp(context))
     {
         return(CreateTimestampWidthElement(context, name, diff, indentLevel));
     }
     else
     {
         string            type      = Hl7DataTypeName.GetParameterizedType(context.Type);
         PropertyFormatter formatter = FormatterRegistry.GetInstance().Get(type);
         if (formatter != null)
         {
             bool isSpecializationType = false;
             return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, isSpecializationType
                                                                                                               , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), name, context), WrapWithHl7DataType
                                         (type, diff), indentLevel));
         }
         else
         {
             throw new ModelToXmlTransformationException("No formatter found for " + type);
         }
     }
 }
コード例 #5
0
        public override string Format(FormatContext formatContext, BareANY hl7Value, int indentLevel)
        {
            if (hl7Value == null)
            {
                return(string.Empty);
            }
            string           specializationType       = hl7Value.DataType.Type;
            StandardDataType specializationTypeAsEnum = StandardDataType.GetByTypeName(specializationType);

            if (specializationTypeAsEnum != null && StandardDataType.ANY.Equals(specializationTypeAsEnum.RootDataType))
            {
                // specializationType has been determined to be an ANY variant; this (most likely) means specializationType has not been specified, so don't do any special processing
                return(base.Format(formatContext, hl7Value, indentLevel));
            }
            else
            {
                string            mappedSpecializationType = this.polymorphismHandler.MapCdaR1Type(hl7Value.DataType, formatContext.IsCda());
                PropertyFormatter formatter  = FormatterRegistry.GetInstance().Get(mappedSpecializationType);
                string            parentType = formatContext.Type;
                if (formatter == null || !AnyHelper.IsValidTypeForAny(parentType, specializationType))
                {
                    string errorText = "Cannot support properties of type " + specializationType + " for " + parentType + ". Please specify a specializationType applicable for "
                                       + parentType + " in the appropriate message bean.";
                    throw new ModelToXmlTransformationException(errorText);
                }
                else
                {
                    // pass processing off to the formatter applicable for the given specializationType
                    StandardDataType type = hl7Value.DataType;
                    return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(formatContext.GetModelToXmlResult
                                                                                                                          (), formatContext.GetPropertyPath(), formatContext.GetElementName(), mappedSpecializationType, type.Coded ? "Code" : formatContext
                                                                                                                      .GetDomainType(), formatContext.GetConformanceLevel(), formatContext.GetCardinality(), true, formatContext.GetVersion(),
                                                                                                                      formatContext.GetDateTimeZone(), formatContext.GetDateTimeTimeZone(), null, formatContext.GetConstraints(), formatContext
                                                                                                                      .IsCda()), hl7Value, indentLevel));
                }
            }
        }
コード例 #6
0
 public virtual void SetUp()
 {
     this.formatter = new SetPropertyFormatter(FormatterRegistry.GetInstance());
 }
コード例 #7
0
 public ListPropertyFormatter(FormatterRegistry formatterRegistry) : base(formatterRegistry, false)
 {
 }
コード例 #8
0
 public virtual void TestShouldFindListIiOidFormatter()
 {
     Assert.IsNotNull(FormatterRegistry.GetInstance().Get("LIST<II.OID>"), "formatter");
 }