Exemple #1
0
        //=============== Write ==================================================
        public override System.Threading.Tasks.Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
        {
            return(System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                XmlWriter writer = new XmlTextWriter(writeStream, new System.Text.UTF8Encoding(false));
                if (type.IsAssignableFrom(typeof(Resource)))
                {
                    Resource Resource = (Resource)value;

                    var Summary = SummaryType.False;
                    if (Resource is IAnnotated Annotated)
                    {
                        var SummaryTypeAnnotationList = Annotated.Annotations(typeof(SummaryType));
                        if (SummaryTypeAnnotationList.FirstOrDefault() is SummaryType AnnotationSummary)
                        {
                            Summary = AnnotationSummary;
                        }
                    }

                    FhirXmlSerializer FhirXmlSerializer = new FhirXmlSerializer();
                    FhirXmlSerializer.Serialize(Resource, writer, Summary);

                    //Now obsolete in FHRI .NET API
                    //FhirSerializer.SerializeResource(Resource, writer, Summary);
                }
                writer.Flush();
                return System.Threading.Tasks.Task.CompletedTask;
            }));
        }
Exemple #2
0
        //=============== Write ==================================================
        public override System.Threading.Tasks.Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
        {
            StreamWriter writer = new StreamWriter(writeStream);
            // This will use the BetterJsonWriter which handles precision correctly
            JsonWriter jsonwriter = SerializationUtil.CreateJsonTextWriter(writer);

            if (typeof(Resource).IsAssignableFrom(type))
            {
                if (value != null)
                {
                    Resource Resource = value as Resource;

                    var Summary = SummaryType.False;
                    if (Resource is IAnnotated Annotated)
                    {
                        var SummaryTypeAnnotationList = Annotated.Annotations(typeof(SummaryType));
                        if (SummaryTypeAnnotationList.FirstOrDefault() is SummaryType AnnotationSummary)
                        {
                            Summary = AnnotationSummary;
                        }
                    }

                    FhirJsonSerializer FhirJsonSerializer = new FhirJsonSerializer();
                    FhirJsonSerializer.Serialize(Resource, jsonwriter, Summary);

                    //Now obsolete in FHIR .NET API
                    //FhirSerializer.SerializeResource(Resource, jsonwriter, Summary);
                }
            }
            writer.Flush();
            return(System.Threading.Tasks.Task.CompletedTask);
        }
        public void ToStorableEvent_restores_Id_from_metadata()
        {
            Event e = new Annotated <CustomerAccount>("hi");

            e.Metadata.AbsoluteSequenceNumber = 123;

            e.ToStorableEvent().Id.Should().Be(123);
        }
        public void ToStorableEvent_restores_Id_from_metadata()
        {
            Event e = new Annotated<CustomerAccount>("hi");

            e.Metadata.AbsoluteSequenceNumber = 123;

            e.ToStorableEvent().Id.Should().Be(123);
        }
        public void ToStorableEvent_does_not_throw_when_actor_is_null()
        {
            Event e = new Annotated <CustomerAccount>("hi");

            e.SetActor((string)null);

            Action toStorableEvent = () => e.ToStorableEvent();

            toStorableEvent.ShouldNotThrow();
        }
        public void ToStorableEvent_does_not_throw_when_actor_is_null()
        {
            Event e = new Annotated<CustomerAccount>("hi");

            e.SetActor((string) null);

            Action toStorableEvent = () => e.ToStorableEvent();

            toStorableEvent.ShouldNotThrow();
        }
 public Annotated Any(Annotated request)
 {
     return request;
 }