protected override void Load(ContainerBuilder builder) { var assemblies = GetAssembliesFromBaseDirectory(); builder.RegisterType <ReadQueryHandler>().Keyed <IQueryHandler>("Read"); builder.Register(a => new HttpClient()).As <HttpClient>().InstancePerDependency(); builder.Register(a => { var settings = this.careRecordSettings; // a.Resolve<CareRecordAPISettings>();//GetSparkSettingsInstance(a);// return(new FhirJsonParser(settings.ParserSettings)); }).AsSelf().InstancePerLifetimeScope(); builder.Register(a => { var settings = this.careRecordSettings; // a.Resolve<CareRecordAPISettings>();//GetSparkSettingsInstance(a);// return(new FhirXmlParser(settings.ParserSettings)); }).AsSelf().InstancePerLifetimeScope(); builder.Register(a => { var settings = this.careRecordSettings; // a.Resolve<CareRecordAPISettings>();// GetSparkSettingsInstance(a);// return(new FhirJsonSerializer(settings.SerializerSettings)); }).AsSelf().InstancePerLifetimeScope(); builder.Register(a => { var settings = this.careRecordSettings; // a.Resolve<CareRecordAPISettings>();// GetSparkSettingsInstance(a);// return(new FhirXmlSerializer(settings.SerializerSettings)); }).AsSelf().InstancePerLifetimeScope(); //Not working should re-look builder.Register <CareRecordAPISettings>(a => { CareRecordAPISettings settings = new CareRecordAPISettings(); var configuration = a.Resolve <IConfiguration>(); configuration.Bind("CareRecordSettings", settings); return(settings); }); builder.Register(a => this.careRecordSettings).AsSelf().SingleInstance(); //builder.RegisterGeneric(typeof(SynapseResourceService<>)) // .As(typeof(ISynapseResourceService<>)) // .InstancePerLifetimeScope(); //builder.RegisterAssemblyTypes(assemblies) // .Where(t => t.BaseType == typeof(Profile)) // .As<Profile>(); // Add all the types as providing its own type as service + all implemented interfaces builder.RegisterAssemblyTypes(assemblies) .AsSelf() .AsImplementedInterfaces(); // register all the modules in the assemblies scanned var exceptCurrentAssemblyModule = assemblies.Except(new[] { Assembly.GetExecutingAssembly() }).ToArray(); builder.RegisterAssemblyModules(exceptCurrentAssemblyModule); }
public void ConfigureServices(IServiceCollection services) { // If using Kestrel: services.Configure <KestrelServerOptions>(options => { options.AllowSynchronousIO = true; }); // If using IIS: services.Configure <IISServerOptions>(options => { options.AllowSynchronousIO = true; }); // Bind to CareRecordAPISettings settings from appSettings.json careRecordSettings = new CareRecordAPISettings(); Configuration.Bind("CareRecordSettings", careRecordSettings); services.AddSingleton <CareRecordAPISettings>(careRecordSettings); services.AddAuthenticationToCareRecord(Configuration); //services.AddMvc(options => //{ // options.Filters.Add(new GlobalFilter()); //}); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddAutoMapperToCareRecord(); // AddFhir also calls AddMvcCore services.AddFhir(careRecordSettings); services.AddFhirFormatters(); //services.AddMvcCore(options => services.AddMvc(options => { options.Filters.Add(new GlobalFilter()); //Should un-comment this (below two lines) to enable it only for FHIR Parsers options.InputFormatters.RemoveType <SystemTextJsonInputFormatter>(); options.OutputFormatters.RemoveType <SystemTextJsonOutputFormatter>(); }); services.AddHttpContextAccessor(); string SynapseDynamicAPIURI = Configuration.GetSection("DynamicAPISettings").GetSection("uri").Value; //services.AddHttpClient(); //services.AddHttpClient<DynamicAPIClient>(clientConfig => //{ // clientConfig.BaseAddress = new Uri(SynapseDynamicAPIURI); //}); services.AddControllers(); services.AddApiVersioning(config => { config.DefaultApiVersion = new ApiVersion(1, 0); config.AssumeDefaultVersionWhenUnspecified = true; config.ReportApiVersions = true; //config.ApiVersionReader = new HeaderApiVersionReader("api-version"); }); services.AddVersionedApiExplorer( options => { // note: the specified format code will format the version as "'v'major[.minor]" options.GroupNameFormat = "'v'V"; options.SubstituteApiVersionInUrl = true; //options.SubstitutionFormat = "'v'V"; }); services.AddHealthChecks().AddCheck("self", () => HealthCheckResult.Healthy()); services.AddSwaggerToCareRecord(Configuration); }
public AutofacBootstrapModule(IConfiguration configuration, CareRecordAPISettings careRecordSettings) { this.configuration = configuration; this.careRecordSettings = careRecordSettings; }
public static void AddFhir(this IServiceCollection services, CareRecordAPISettings settings, Action <MvcOptions> setupAction = null) { //AddFhirFormatters(). }