Ejemplo n.º 1
0
        /// <summary>
        /// Displays the serialized FHIR result to the console with timing information.
        /// </summary>
        public void DisplayFhirResultDebugTimer(ResourceFormat resourceFormat = ResourceFormat.Xml)
        {
            var s = new Stopwatch();

            s.Start();

            if (resourceFormat == ResourceFormat.Json)
            {
                foreach (var line in SerializedResourceBundleJson.Split(new[] { "\n" }, StringSplitOptions.None))
                {
                    Console.WriteLine(line);
                }
            }
            // return in XML if the requested resource format isn't JSON
            else
            {
                foreach (var line in SerializedResourceBundleXml.Split(new[] { "\n" }, StringSplitOptions.None))
                {
                    if (line.Contains("\""))
                    {
                        var parts = line.Split(new[] { "\"" }, StringSplitOptions.None);
                        for (var i = 0; i < parts.Length; i++)
                        {
                            var part = parts[i];
                            switch (i)
                            {
                            case 0:
                                Console.Write(part);
                                break;

                            case 1:
                                Console.Write("\"" + part + "\"", Console.ForegroundColor = ConsoleColor.Green);
                                Console.ResetColor();
                                break;

                            case 2:
                                Console.Write(part + "\n");
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(line);
                    }
                }
            }

            s.Stop();
            var timeTaken = s.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture);

            Console.WriteLine($"\nFormatting FHIR took {timeTaken} secs.", Console.ForegroundColor = ConsoleColor.Cyan);
            Console.ResetColor();
        }
Ejemplo n.º 2
0
        // ======================
        // Debug & Timing Methods
        // ======================

        /// <summary>
        /// Displays the serialized FHIR result to the console.
        /// </summary>
        public void DisplayFhirResult(ResourceFormat resourceFormat = ResourceFormat.Xml)
        {
            if (resourceFormat == ResourceFormat.Json)
            {
                foreach (var line in SerializedResourceBundleJson.Split(new[] { "\n" }, StringSplitOptions.None))
                {
                    Console.WriteLine(line);
                }
            }
            // return in XML if the requested resource format isn't JSON
            else
            {
                foreach (var line in SerializedResourceBundleXml.Split(new[] { "\n" }, StringSplitOptions.None))
                {
                    if (line.Contains("\""))
                    {
                        var parts = line.Split(new[] { "\"" }, StringSplitOptions.None);
                        for (var i = 0; i < parts.Length; i++)
                        {
                            var part = parts[i];
                            switch (i)
                            {
                            case 0:
                                Console.Write(part);
                                break;

                            case 1:
                                Console.Write("\"" + part + "\"", Console.ForegroundColor = ConsoleColor.Green);
                                Console.ResetColor();
                                break;

                            case 2:
                                Console.Write(part + "\n");
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(line);
                    }
                }
            }
        }