-
Notifications
You must be signed in to change notification settings - Fork 134
/
Program.cs
48 lines (43 loc) · 1.98 KB
/
Program.cs
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
using GridBlazor;
using GridBlazorGrpc.Client.Services;
using GridBlazorGrpc.Shared.Models;
using GridShared;
using GridShared.Style;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.JSInterop;
using System;
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
namespace GridBlazorGrpc.Client
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddSingleton(new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<IGridClientService, GridClientService>();
builder.Services.AddScoped<ICrudDataService<Order>, OrderClientService>();
builder.Services.AddScoped<IOrderGridInMemoryService, OrderGridInMemoryService>();
builder.Services.AddScoped<ICrudDataService<OrderDetail>, OrderDetailClientService>();
builder.Services.AddScoped<ICrudDataService<Customer>, CustomerClientService>();
builder.Services.AddScoped<ICrudDataService<Employee>, EmployeeClientService>();
builder.Services.AddScoped<ICrudFileService<Employee>, EmployeeFileService>();
builder.Services.AddLocalization();
builder.Services.AddGridBlazor(x => x.Style = CssFramework.Bootstrap_4);
var host = builder.Build();
var jsInterop = host.Services.GetRequiredService<IJSRuntime>();
var result = await jsInterop.InvokeAsync<string>("blazorCulture.get");
if (result != null)
{
var culture = new CultureInfo(result);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}
await builder.Build().RunAsync();
}
}
}