This repository was archived by the owner on Apr 30, 2023. It is now read-only.
forked from PrimeN/Total-Script-Blocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (47 loc) · 2.07 KB
/
Program.cs
File metadata and controls
52 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using Blazored.LocalStorage;
using Lkhsoft.Utility;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using MudBlazor.Services;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Total_Script_Blocker_II.Services;
namespace Total_Script_Blocker_II
{
public static class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#TotalScriptBlockerIIApp");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
/* Serilog configuration
* here I use BrowserHttp sink to send log entries to my Server app
*/
var levelSwitch = new LoggingLevelSwitch();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("n"))
.WriteTo.BrowserConsole(
LogEventLevel.Information,
"[{Timestamp:HH:mm:ss} {Level:u2}] {Message:lj}{NewLine}{Exception}",
CultureInfo.CurrentUICulture)
.CreateLogger();
/* this is used instead of .UseSerilog to add Serilog to providers */
builder.Logging.AddSerilog();
builder.Services.AddScoped<IJsonSerializer, JsonSerializer>();
builder.Services.AddScoped<IBlocker, Blocker>();
builder.Services.AddMudServices();
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddBrowserExtensionServices();
await builder.Build().RunAsync();
}
}
}