TourIAm/TIAMWebApp/Client/Program.cs

91 lines
3.8 KiB
C#

using AyCode.Interfaces.StorageHandlers;
using BlazorAnimation;
using Blazored.LocalStorage;
using DevExpress.Blazor;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using System.Resources;
using TIAMWebApp.Client;
using TIAMWebApp.Client.Services;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Services;
using TIAMWebApp.Shared.Application.Utility;
using AyCode.Services.Loggers;
using System.Net;
using AyCode.Core.Loggers;
using Microsoft.AspNetCore.Components.Authorization;
using TIAM.Models;
using TIAM.Models.PageViewModels;
using Microsoft.Extensions.DependencyInjection;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddLocalization();
builder.Services.AddSingleton<IWeatherForecastService, WeatherForecastService>();
builder.Services.AddSingleton<ITransferDataService, TransferDataService>();
builder.Services.AddSingleton<IPopulationStructureDataProvider, PopulationStructureDataProvider>();
builder.Services.AddSingleton<ISupplierService, SupplierService>();
builder.Services.AddSingleton<IUserDataService, UserDataServiceWeb>();
builder.Services.AddSingleton<ISecureStorageHandler, SecureStorageHandler>();
builder.Services.AddBlazoredLocalStorageAsSingleton();
builder.Services.AddSingleton<ISessionServiceClient, SessionServiceWeb>();
builder.Services.AddSingleton<IComponentUpdateService, ComponentUpdateServiceWeb>();
builder.Services.AddSingleton<IServiceProviderDataService, ServiceProviderDataService>();
builder.Services.AddSingleton<IClientNoticeSenderService, ClientNoticeSenderService>();
builder.Services.AddSingleton<IWizardProcessor, WizardProcessor>();
builder.Services.AddSingleton<IImageDataService, ImageDataService>();
//WebSpecific
builder.Services.AddSingleton<SessionStorageAccessor>();
builder.Services.AddSingleton(x => new ResourceManager("TIAMWebApp.Client.Resources.MyResources", typeof(Program).Assembly));
#if DEBUG
builder.Services.AddSingleton<IAcLogWriterClientBase, BrowserConsoleLogWriter>();
#endif
builder.Services.AddSingleton<IAcLogWriterClientBase, SignaRClientLogItemWriter>();
//builder.Services.AddSingleton<IAcLogWriterClientBase, HttpClientLogItemWriter>();
builder.Services.AddSingleton<AdminSignalRClient>();
builder.Services.AddSingleton<SignalRService>();
builder.Services.AddSingleton<SumupService>();
builder.Services.AddSingleton<AuthenticationStateProvider, CustomAuthStateProvider>();
builder.Services.AddAuthorizationCore();
builder.Services.AddSingleton<ExchangeRateService>();
builder.Services.AddSingleton<SmartyStreetsService>();
builder.Services.AddSingleton<GooglePlacesService>();
builder.Services.AddSingleton<PageHistoryState>();
builder.Services.AddScoped<BlogService>();
builder.Services.AddScoped<TourService>();
//builder.Services.AddScoped<BrowserConsoleLogWriter>();
//WebSpecific end
//AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
//{
// Console.WriteLine("********** OMG! FirstChanceException **********");
// Console.WriteLine(e.Exception);
//};
//
//AppDomain.CurrentDomain.UnhandledException += (s, e) =>
//{
// Console.WriteLine("********** OMG! UnhandledException **********");
// Console.WriteLine(e.ExceptionObject.ToString());
//};
builder.Services.AddSingleton(sp => new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress),
DefaultRequestVersion = HttpVersion.Version20,
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher
});
builder.Services.AddDevExpressBlazor(configure => configure.BootstrapVersion = BootstrapVersion.v5);
builder.Services.Configure<AnimationOptions>(Guid.NewGuid().ToString(), c => { });
await builder.Build().RunAsync();