コード例 #1
0
        /// <summary>
        /// This method provides temporary compatibility while STU3/R4 compatibility is added
        /// </summary>
        public static void SetModelInfoProvider()
        {
#if Stu3
            ModelInfoProvider.SetProvider(new Stu3ModelInfoProvider());
#elif R4
            ModelInfoProvider.SetProvider(new R4ModelInfoProvider());
#endif
        }
コード例 #2
0
 /// <summary>
 /// This method provides temporary compatibility while STU3/R4 compatibility is added
 /// </summary>
 public static void SetModelInfoProvider()
 {
     ModelInfoProvider.SetProvider(new VersionSpecificModelInfoProvider());
 }
コード例 #3
0
ファイル: FhirModule.cs プロジェクト: weyls/fhir-server
        /// <inheritdoc />
        public void Load(IServiceCollection services)
        {
            EnsureArg.IsNotNull(services, nameof(services));

            var jsonParser     = new FhirJsonParser();
            var jsonSerializer = new FhirJsonSerializer();

            var xmlParser     = new FhirXmlParser();
            var xmlSerializer = new FhirXmlSerializer();

            services.AddSingleton(jsonParser);
            services.AddSingleton(jsonSerializer);
            services.AddSingleton(xmlParser);
            services.AddSingleton(xmlSerializer);

            ResourceElement SetMetadata(Resource resource, string versionId, DateTimeOffset lastModified)
            {
                resource.VersionId        = versionId;
                resource.Meta.LastUpdated = lastModified;
                return(resource.ToResourceElement());
            }

            services.AddSingleton <IReadOnlyDictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> > >(_ =>
            {
                return(new Dictionary <FhirResourceFormat, Func <string, string, DateTimeOffset, ResourceElement> >
                {
                    {
                        FhirResourceFormat.Json, (str, version, lastModified) =>
                        {
                            var resource = jsonParser.Parse <Resource>(str);
                            return SetMetadata(resource, version, lastModified);
                        }
                    },
                    {
                        FhirResourceFormat.Xml, (str, version, lastModified) =>
                        {
                            var resource = xmlParser.Parse <Resource>(str);
                            return SetMetadata(resource, version, lastModified);
                        }
                    },
                });
            });

            services.AddSingleton <ResourceDeserializer>();

            services.Add <FormatterConfiguration>()
            .Singleton()
            .AsSelf()
            .AsService <IPostConfigureOptions <MvcOptions> >()
            .AsService <IProvideCapability>();

            services.AddSingleton <IContentTypeService, ContentTypeService>();
            services.AddSingleton <OperationOutcomeExceptionFilterAttribute>();
            services.AddSingleton <ValidateContentTypeFilterAttribute>();
            services.AddSingleton <ValidateExportRequestFilterAttribute>();

            // HTML
            // If UI is supported, then add the formatter so that the
            // document can be output in HTML view.
            if (_featureConfiguration.SupportsUI)
            {
                services.Add <HtmlOutputFormatter>()
                .Singleton()
                .AsSelf()
                .AsService <TextOutputFormatter>();
            }

            services.Add <FhirJsonInputFormatter>()
            .Singleton()
            .AsSelf()
            .AsService <TextInputFormatter>();

            services.Add <FhirJsonOutputFormatter>()
            .Singleton()
            .AsSelf()
            .AsService <TextOutputFormatter>();

            if (_featureConfiguration.SupportsXml)
            {
                services.Add <FhirXmlInputFormatter>()
                .Singleton()
                .AsSelf()
                .AsService <TextInputFormatter>();

                services.Add <FhirXmlOutputFormatter>()
                .Singleton()
                .AsSelf()
                .AsService <TextOutputFormatter>();
            }

            services.Add <FhirRequestContextAccessor>()
            .Singleton()
            .AsSelf()
            .AsService <IFhirRequestContextAccessor>();

            services.AddSingleton <CorrelationIdProvider>(_ => () => Guid.NewGuid().ToString());

            // Add conformance provider for implementation metadata.
            services.AddSingleton <IConfiguredConformanceProvider, DefaultConformanceProvider>();

            services.Add <ConformanceProvider>()
            .Singleton()
            .AsSelf()
            .AsService <IConformanceProvider>();

            services.Add <SystemConformanceProvider>()
            .Singleton()
            .AsSelf()
            .AsService <ISystemConformanceProvider>();

            services.Add <SecurityProvider>()
            .Singleton()
            .AsSelf()
            .AsService <IProvideCapability>();

            services.TypesInSameAssembly(KnownAssemblies.Core, KnownAssemblies.CoreStu3)
            .AssignableTo <IProvideCapability>()
            .Transient()
            .AsService <IProvideCapability>();

            services.AddSingleton <INarrativeHtmlSanitizer, NarrativeHtmlSanitizer>();

            var stu3ModelFactory = new Stu3ModelInfoProvider();

            services.Add(_ => stu3ModelFactory).Singleton().AsSelf().AsImplementedInterfaces();
            ModelInfoProvider.SetProvider(stu3ModelFactory);

            // Register a factory to resolve a scope that returns all components that provide capabilities
            services.AddFactory <IScoped <IEnumerable <IProvideCapability> > >();

            services.AddLazy();
            services.AddScoped();
        }
コード例 #4
0
ファイル: ModelExtensions.cs プロジェクト: weyls/fhir-server
 /// <summary>
 /// This method provides temporary compatibility while STU3/R4 compatibility is added
 /// </summary>
 internal static void SetModelInfoProvider()
 {
     ModelInfoProvider.SetProvider(new Stu3ModelInfoProvider());
 }