mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
* Rename avalonia & wpf samples * Rename rest of samples * fix sample readme * Fix compat util tests * rename / move all src projects * remove package lock files and move libC# again * Add rust lib and cargo workspace * Replace locksmith lib with new filelocksmith-rs library * Deprecated type * fix setup compile * Use thiserror for error handling * Rename some enums and formatting * Add missing SHA256 * wip c++ library * cpp wip * alphabetize readme * Try to get build working again * Fix some conditionally compiled bits * cross config should be in workspace root * Fix PathHelper for new rust target dir * Missed one old path to velopack.csproj * remove obsolete coverage code * testawareapp.exe no longer exists
117 lines
4.6 KiB
C#
117 lines
4.6 KiB
C#
using Uno.Resizetizer;
|
|
using Velopack;
|
|
|
|
namespace UnoSample;
|
|
public partial class App : Application
|
|
{
|
|
/// <summary>
|
|
/// Initializes the singleton application object. This is the first line of authored code
|
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
|
/// </summary>
|
|
public App()
|
|
{
|
|
// It's important to Run() the VelopackApp as early as possible in app startup.
|
|
VelopackApp.Build()
|
|
.WithFirstRun((v) => { /* Your first run code here */ })
|
|
.Run();
|
|
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
protected Window? MainWindow { get; private set; }
|
|
protected IHost? Host { get; private set; }
|
|
|
|
protected async override void OnLaunched(LaunchActivatedEventArgs args)
|
|
{
|
|
var builder = this.CreateBuilder(args)
|
|
// Add navigation support for toolkit controls such as TabBar and NavigationView
|
|
.UseToolkitNavigation()
|
|
.Configure(host => host
|
|
#if DEBUG
|
|
// Switch to Development environment when running in DEBUG
|
|
.UseEnvironment(Environments.Development)
|
|
#endif
|
|
.UseLogging(configure: (context, logBuilder) =>
|
|
{
|
|
// Configure log levels for different categories of logging
|
|
logBuilder
|
|
.SetMinimumLevel(
|
|
context.HostingEnvironment.IsDevelopment() ?
|
|
LogLevel.Information :
|
|
LogLevel.Warning)
|
|
|
|
// Default filters for core Uno Platform namespaces
|
|
.CoreLogLevel(LogLevel.Warning);
|
|
|
|
// Uno Platform namespace filter groups
|
|
// Uncomment individual methods to see more detailed logging
|
|
//// Generic Xaml events
|
|
//logBuilder.XamlLogLevel(LogLevel.Debug);
|
|
//// Layout specific messages
|
|
//logBuilder.XamlLayoutLogLevel(LogLevel.Debug);
|
|
//// Storage messages
|
|
//logBuilder.StorageLogLevel(LogLevel.Debug);
|
|
//// Binding related messages
|
|
//logBuilder.XamlBindingLogLevel(LogLevel.Debug);
|
|
//// Binder memory references tracking
|
|
//logBuilder.BinderMemoryReferenceLogLevel(LogLevel.Debug);
|
|
//// DevServer and HotReload related
|
|
//logBuilder.HotReloadCoreLogLevel(LogLevel.Information);
|
|
//// Debug JS interop
|
|
//logBuilder.WebAssemblyLogLevel(LogLevel.Debug);
|
|
|
|
}, enableUnoLogging: true)
|
|
.UseConfiguration(configure: configBuilder =>
|
|
configBuilder
|
|
.EmbeddedSource<App>()
|
|
.Section<AppConfig>()
|
|
)
|
|
// Enable localization (see appsettings.json for supported languages)
|
|
.UseLocalization()
|
|
// Register Json serializers (ISerializer and ISerializer)
|
|
.UseSerialization((context, services) => services
|
|
.AddContentSerializer(context)
|
|
.AddJsonTypeInfo(WeatherForecastContext.Default.IImmutableListWeatherForecast))
|
|
.UseHttp((context, services) => services
|
|
// Register HttpClient
|
|
#if DEBUG
|
|
// DelegatingHandler will be automatically injected into Refit Client
|
|
.AddTransient<DelegatingHandler, DebugHttpHandler>()
|
|
#endif
|
|
.AddSingleton<IWeatherCache, WeatherCache>()
|
|
.AddRefitClient<IApiClient>(context))
|
|
.ConfigureServices((context, services) =>
|
|
{
|
|
// TODO: Register your services
|
|
//services.AddSingleton<IMyService, MyService>();
|
|
})
|
|
.UseNavigation(RegisterRoutes)
|
|
);
|
|
MainWindow = builder.Window;
|
|
|
|
#if DEBUG
|
|
MainWindow.EnableHotReload();
|
|
#endif
|
|
MainWindow.SetWindowIcon();
|
|
|
|
Host = await builder.NavigateAsync<Shell>();
|
|
}
|
|
|
|
private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
|
|
{
|
|
views.Register(
|
|
new ViewMap(ViewModel: typeof(ShellViewModel)),
|
|
new ViewMap<MainPage, MainViewModel>()
|
|
);
|
|
|
|
routes.Register(
|
|
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
|
|
Nested:
|
|
[
|
|
new ("Main", View: views.FindByViewModel<MainViewModel>())
|
|
]
|
|
)
|
|
);
|
|
}
|
|
}
|