-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Joker.OData] - program file migrated to Top-level statements
- Loading branch information
1 parent
be7297b
commit 0f0edcd
Showing
1 changed file
with
43 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,54 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Joker.OData.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using SelfHostedODataService.EFCore; | ||
using SelfHostedODataService.EFCore.HostedServices; | ||
using SelfHostedODataService.HostedServices; | ||
using Serilog; | ||
|
||
namespace SelfHostedODataService.EFCore | ||
var startupSettings = new KestrelODataWebHostConfig() | ||
{ | ||
public class Program | ||
ConfigureServices = services => | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var startupSettings = new KestrelODataWebHostConfig() | ||
{ | ||
ConfigureServices = services => | ||
{ | ||
services.AddHostedService<ProductChangesHostedService>(); | ||
services.AddHostedService<SqlTableDependencyProviderHostedService>(); | ||
} | ||
}; | ||
|
||
ConfigureLogging(); | ||
|
||
await new ODataHost().RunAsync(args, startupSettings); | ||
} | ||
|
||
private static void ConfigureLogging() | ||
{ | ||
var baseDir = AppDomain.CurrentDomain.BaseDirectory; | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console() | ||
.WriteTo.File($@"{baseDir}\logs\{nameof(ODataHost)}_.txt", rollingInterval: RollingInterval.Day) | ||
.CreateLogger(); | ||
|
||
Log.Information("Hello, world!"); | ||
} | ||
|
||
#region IISODataWebHostConfig example | ||
|
||
private static ODataWebHostConfig ODataStartupConfigExample() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.AddEnvironmentVariables() | ||
.Build(); | ||
|
||
var startupSettings = new IISODataWebHostConfig() | ||
{ | ||
ConfigureServices = services => { services.AddHostedService<SqlTableDependencyProviderHostedService>(); }, | ||
Urls = new[] { @"https://localhost:32778/" }, | ||
Configuration = configuration | ||
}; | ||
|
||
return startupSettings; | ||
} | ||
|
||
#endregion | ||
services.AddHostedService<ProductChangesHostedService>(); | ||
services.AddHostedService<SqlTableDependencyProviderHostedService>(); | ||
} | ||
} | ||
}; | ||
|
||
ConfigureLogging(); | ||
|
||
await new ODataHost().RunAsync(args, startupSettings); | ||
|
||
static void ConfigureLogging() | ||
{ | ||
var baseDir = AppDomain.CurrentDomain.BaseDirectory; | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.WriteTo.Console() | ||
.WriteTo.File($@"{baseDir}\logs\{nameof(ODataHost)}_.txt", rollingInterval: RollingInterval.Day) | ||
.CreateLogger(); | ||
|
||
Log.Information("Hello, world!"); | ||
} | ||
|
||
#region IISODataWebHostConfig example | ||
|
||
static ODataWebHostConfig ODataStartupConfigExample() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
.AddEnvironmentVariables() | ||
.Build(); | ||
|
||
var startupSettings = new IISODataWebHostConfig() | ||
{ | ||
ConfigureServices = services => { services.AddHostedService<SqlTableDependencyProviderHostedService>(); }, | ||
Urls = ["https://localhost:32778/"], | ||
Configuration = configuration | ||
}; | ||
|
||
return startupSettings; | ||
} | ||
|
||
#endregion |