-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathApp.cs
More file actions
74 lines (59 loc) · 2.21 KB
/
Copy pathApp.cs
File metadata and controls
74 lines (59 loc) · 2.21 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using DotNetLab.Lab;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.Hosting;
using Microsoft.FluentUI.AspNetCore.Components;
namespace DotNetLab;
public partial class App
{
public const string Domain = "lab.razor.fyi";
public const string DesktopAppLink = "https://apps.microsoft.com/detail/9PCPMM329DZT";
public static void RegisterRootComponents(Action<Type, string> adder)
{
adder(typeof(App), "#app");
adder(typeof(HeadOutlet), "head::after");
}
public static void RegisterServices(IServiceCollection services)
{
services.AddScoped<ILocalStorageService, LocalStorageService>();
services.AddFluentUIComponents();
services.AddScoped<WorkerController>();
services.AddScoped<BlazorMonacoInterop>();
services.AddScoped<CursorSynchronizer.Services>();
services.AddScoped<LanguageServicesClient>();
services.AddScoped<InputOutputCache>();
services.AddScoped<TemplateCache>();
services.AddLogging(builder =>
{
builder.AddFilter("DotNetLab.*",
static (logLevel) => logLevel >= Logging.LogLevel);
});
}
public static void Initialize(IServiceProvider services)
{
var appHostEnvironment = services.GetRequiredService<IAppHostEnvironment>();
if (appHostEnvironment.IsDevelopment)
{
Logging.LogLevel = LogLevel.Debug;
}
services.GetRequiredService<ILogger<App>>()
.LogInformation("Environment: {Environment}", appHostEnvironment.Environment);
}
}
public interface IAppHostEnvironment
{
string Environment { get; }
string BaseAddress { get; }
string? LabUrlPrefix { get; }
DesktopAppLink? DesktopAppLink { get; }
bool SupportsWebWorkers { get; }
bool SupportsThreads { get; }
ValueTask<bool> HasHardwareKeyboardAsync();
sealed bool IsDevelopment => Environments.Development.Equals(Environment, StringComparison.OrdinalIgnoreCase);
}
public sealed record DesktopAppLink
{
public required string Url { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public Action? OnClick { get; init; }
}