To install and successfully use this nuget package, please do the following:
-
Create a .net core 3.1 application (no other versions currently supported)
-
Install the nuget package Sphyrnidae.Common - eg. Install-Package Sphyrnidae.Common
-
Create a folder in your project called "Settings" (or "Implementations" or "Overrides" or whatever makes sense)
-
Project-specific implementations (to be placed inside this folder):
-
IApplicationSettings: see Application for more information. Call this class <project>ApplicationSettings
-
IFeatureToggleSettings: see Feature Toggle for more information
-
IUserPreferenceSettings: see User Preferences for more information
-
IVariableSettings: see Variables for more information
-
ILoggerConfiguration: see Logging Configurations for more information
-
Update the program.cs class to include environmental variables: CreateHostBuilder() => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }).ConfigureAppConfiguration((hostingContext, config) => { config.AddEnvironmentVariables(); });
-
Update your startup.cs class to:
-
Inject IConfiguration into the constructor (save this reference off) - will call this "Config"
-
Instantiate and save off a new instance of ServiceConfiguration - will call this "ServiceConfig"
-
Register your project-specific implementations in ConfigureServices():
-
IApplicationSettings
-
IFeatureToggleSettings
-
IUserPreferenceSettings
-
IVariableSettings
-
ILoggerConfiguration
-
Last thing in ConfigureServices() should be the call to services.AddCommonServices() - note that it takes the ServiceConfiguration, as well as 3 other concrete instances:
-
var app = new <project>ApplicationSettings()
-
var env = new EnvironmentalSettings(Config)
-
var http = new HttpClientSettings(null, env)
-
In Configure(), replace the entire configuration/pipeline with a single call to: app.UseServices(ServiceConfig, sp);
-
app: injected IApplicationBuilder
-
ServiceConfig: The saved off ServiceConfiguration
-
sp: injected IServiceProvider
-
In launchSettings.json, ensure the "launchUrl" is configured to be "swagger"
-
Configure Project Settings:
-
Build => Suppress Warnings: 1701;1702;1591
-
Build => Treat warnings as errors => Specific warnings: ;NU1605
-
Build => Output => ENable XML documentations file: obj\Debug\netcoreapp3.1<IApplication.Name> Api.xml
That's the basic setup. As you develop API's, be sure to thoroughly comment them with XML comments. As you look to use other pieces of functionality in this package, there may be additional configurations you'll need to make.