NCI.OCPL.Api.Shared
Common code for the CancerGov APIs.
In order to consume these packages, you must configure the .Net SDK to retrieve NuGet packages from GitHub.
NOTE: These packages are presently built-on version 3.1 of the .Net Core SDK. This is subject to change.
- On GitHub, create a Personal Access Token with a descriptive name such as "Retrieve NuGet Packages."
- Assign the token the
packages:read
scope and save it. - Copy the token's value.
- From the command prompt, and outside any .Net project's directory tree, run the following command (all one line), substituting your username and the token value:
dotnet nuget add source https://nuget.pkg.github.com/nciocpl/index.json --name github --username <YOUR_GITHUB_USERNAME> --password <THE_TOKEN_VALUE> --store-password-in-clear-text
- In the .Net project's cdirectory, run the command:
dotnet add package nci.ocpl.api.common
- Replace the contents of Program.cs with
using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; using NCI.OCPL.Api.Common; namespace my_namespace { public class Program : NciApiProgramBase { public static void Main(string[] args) { CreateHostBuilder<Startup>(args).Build().Run(); } } }
- In Startup.cs
- Add
using NCI.OCPL.Api.Common;
- Change the class declaration to:
public class Startup : NciStartupBase
- Add
- Replace the constructor with:
public Startup(IConfiguration configuration) : base(configuration) { }
- Remove the
ConfigureServices()
andConfigure()
methods. - Add these required overrides:
- See
test/integration-test-harness/Startup.cs
for sample code.protected override void AddAdditionalConfigurationMappings(IServiceCollection services) {} protected override void AddAppServices(IServiceCollection services) {} protected override void ConfigureAppSpecific(IApplicationBuilder app, IWebHostEnvironment env) {}
- See
ESHealthCheckService
with dependency injection, you must register a handler for IESAliasNameProvider
in AddAppServices
. As in:
protected override void AddAppServices(IServiceCollection services)
{
services.AddTransient<IESAliasNameProvider>(p => {
string alias = Configuration["TestIndexOptions:AliasName"];
return new ESAliasNameProvider(){Name= alias};
});
}