/// <summary> /// Creates a new <see cref="INavigatorStream"/> instance to access the contents of a /// serialized resource, independent of the underlying resource serialization format. /// </summary> /// <param name="path">File path specification of a FHIR resource file.</param> /// <returns>A new <see cref="INavigatorStream"/> instance, or <c>null</c> (unsupported file extension).</returns> /// <remarks>Supports FHIR resource files with ".xml" and ".json" extensions.</remarks> public static INavigatorStream Create(string path) { if (FhirFileFormats.HasXmlExtension(path)) { return(XmlNavigatorStream.FromPath(path)); } if (FhirFileFormats.HasJsonExtension(path)) { return(JsonNavigatorStream.FromPath(path)); } // Unsupported extension return(null); }
// Called by DefaultNavigatorStream.Create(string path, bool disposeStream) internal INavigatorStream Create(string path, bool disposeStream) { if (FhirFileFormats.HasXmlExtension(path)) { return(XmlNavigatorStream.FromPath(path, disposeStream, XmlParsingSettings)); } if (FhirFileFormats.HasJsonExtension(path)) { return(JsonNavigatorStream.FromPath(path, disposeStream, JsonParsingSettings)); } // Unsupported extension if (ThrowOnUnsupportedFormat) { throw Error.NotSupported($"Unsupported file format ('{path}')."); } return(null); }