Skip to content

Commit

Permalink
bumping to Oakton 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Aug 29, 2019
1 parent 55a3efa commit 12b9382
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions src/MvcApp/Startup.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -22,25 +24,25 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }

// SAMPLE: ConfigureService-with-EnvironmentCheck
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
// Other registrations we don't care about...

// This extension method is in Oakton.AspNetCore
services.CheckEnvironment<IConfiguration>("Can connect to the application database", config =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
var connectionString = config["connectionString"];
using (var conn = new SqlConnection(connectionString))
{
// Just attempt to open the connection. If there's anything
// wrong here, it's going to throw an exception
conn.Open();
}
});


services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);


services.CheckEnvironment("good", s => {});
services.CheckEnvironment("also good", s => {});
//services.CheckEnvironment("bad", s => throw new DivideByZeroException());
//services.CheckEnvironment("boom", s => throw new Exception("Boom!"));
}
// ENDSAMPLE

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down
2 changes: 1 addition & 1 deletion src/Oakton/Oakton.csproj
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Command Line Parsing and Execution</Description>
<AssemblyTitle>Oakton</AssemblyTitle>
<VersionPrefix>1.6.0</VersionPrefix>
<VersionPrefix>2.0.0</VersionPrefix>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<DebugType>portable</DebugType>
Expand Down

0 comments on commit 12b9382

Please sign in to comment.