private static string convertToXmlString(object value) { return(value switch { bool bl => XmlConvert.ToString(bl), Byte by => XmlConvert.ToString(by), // Not used in FHIR serialization Char cr => XmlConvert.ToString(cr), // Not used in FHIR serialization DateTime dt => XmlConvert.ToString(dt, FMT_FULL), // Obsolete: use DateTimeOffset instead!! decimal dec => XmlConvert.ToString(dec), Double dbl => XmlConvert.ToString(dbl), Int16 i16 => XmlConvert.ToString(i16), Int32 i32 => XmlConvert.ToString(i32), Int64 i64 => XmlConvert.ToString(i64), // Not used in FHIR serialization SByte sb => XmlConvert.ToString(sb), // Not used in FHIR serialization Single sing => XmlConvert.ToString(sing), // Not used in FHIR serialization UInt16 uint16 => XmlConvert.ToString(uint16), // Not used in FHIR serialization UInt32 uint32 => XmlConvert.ToString(uint32), // Not used in FHIR serialization UInt64 uint64 => XmlConvert.ToString(uint64), // Not used in FHIR serialization byte[] barr => System.Convert.ToBase64String(barr), DateTimeOffset dto => XmlConvert.ToString(dto, FMT_FULL), Uri uri => uri.ToString(), PartialDateTime pdt => pdt.ToString(), PartialTime pt => pt.ToString(), PartialDate pd => pd.ToString(), Enum en => en.GetLiteral(), BigInteger bi => bi.ToString(), Quantity q => q.ToString(), _ => throw Error.NotSupported($"Cannot convert '{value.GetType().Name}' value '{value}' to string"), });
private static string GetDisplayText(PartialDate date) { return(date.Month != null?date.ToString("MMM yyyy") : date.ToString("yyyy")); }