Skip to content

Commit

Permalink
Make UseTimeZone cross-platform until https://github.com/dotnet/coref…
Browse files Browse the repository at this point in the history
  • Loading branch information
adamskt committed Jan 4, 2019
1 parent 122d313 commit dafb1e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
19 changes: 13 additions & 6 deletions src/Coalesce.Web.Vue/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.InteropServices;
using Coalesce.Domain;
using IntelliTect.Coalesce;
using IntelliTect.Coalesce.DataAnnotations;
Expand Down Expand Up @@ -30,12 +31,18 @@ public void ConfigureServices(IServiceCollection services)
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

services.AddCoalesce(builder => builder
.AddContext<AppDbContext>()
.UseDefaultDataSource(typeof(MyDataSource<,>))
.UseDefaultBehaviors(typeof(MyBehaviors<,>))
.UseTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"))
);
services.AddCoalesce(builder =>
{
builder
.AddContext<AppDbContext>()
.UseDefaultDataSource(typeof(MyDataSource<,>))
.UseDefaultBehaviors(typeof(MyBehaviors<,>));
// This breaks on non-windows platforms, see https://github.com/dotnet/corefx/issues/11897
builder.UseTimeZone(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")
: TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"));
});

services.AddAuthentication(DemoMiddleware.AuthenticationScheme).AddCookie(DemoMiddleware.AuthenticationScheme);

Expand Down
19 changes: 13 additions & 6 deletions src/Coalesce.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using System;
using System.Runtime.InteropServices;
using IntelliTect.Coalesce;
using Coalesce.Domain.Services;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -39,12 +40,18 @@ public void ConfigureServices(IServiceCollection services)
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

services.AddCoalesce(builder => builder
.AddContext<AppDbContext>()
.UseDefaultDataSource(typeof(MyDataSource<,>))
.UseDefaultBehaviors(typeof(MyBehaviors<,>))
.UseTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"))
);
services.AddCoalesce(builder =>
{
builder
.AddContext<AppDbContext>()
.UseDefaultDataSource(typeof(MyDataSource<,>))
.UseDefaultBehaviors(typeof(MyBehaviors<,>));
// This breaks on non-windows platforms, see https://github.com/dotnet/corefx/issues/11897
builder.UseTimeZone(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")
: TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"));
});

services.AddCors();

Expand Down

0 comments on commit dafb1e9

Please sign in to comment.