using System; using System.ComponentModel; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.ApplicationModel.Communication; using Microsoft.Maui.ApplicationModel.DataTransfer; using Microsoft.Maui.Controls; using Microsoft.Maui.Devices; using Microsoft.Maui.Dispatching; using Microsoft.Maui.Hosting; using Microsoft.Maui.Networking; using Microsoft.Maui.Platform.Linux.Converters; using Microsoft.Maui.Platform.Linux.Dispatching; using Microsoft.Maui.Platform.Linux.Handlers; using Microsoft.Maui.Platform.Linux.Services; using Microsoft.Maui.Storage; using SkiaSharp; namespace Microsoft.Maui.Platform.Linux.Hosting; public static class LinuxMauiAppBuilderExtensions { public static MauiAppBuilder UseLinux(this MauiAppBuilder builder) { return builder.UseLinux(null); } public static MauiAppBuilder UseLinux(this MauiAppBuilder builder, Action? configure) { LinuxApplicationOptions linuxApplicationOptions = new LinuxApplicationOptions(); configure?.Invoke(linuxApplicationOptions); builder.Services.TryAddSingleton((IDispatcherProvider)(object)LinuxDispatcherProvider.Instance); builder.Services.TryAddSingleton((IDeviceInfo)(object)DeviceInfoService.Instance); builder.Services.TryAddSingleton((IDeviceDisplay)(object)DeviceDisplayService.Instance); builder.Services.TryAddSingleton((IAppInfo)(object)AppInfoService.Instance); builder.Services.TryAddSingleton((IConnectivity)(object)ConnectivityService.Instance); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton(); builder.Services.TryAddSingleton((IServiceProvider _) => GtkHostService.Instance); RegisterTypeConverters(); HandlerMauiAppBuilderExtensions.ConfigureMauiHandlers(builder, (Action)delegate(IMauiHandlersCollection handlers) { handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); }); builder.Services.AddSingleton(linuxApplicationOptions); return builder; } private static void RegisterTypeConverters() { TypeDescriptor.AddAttributes(typeof(SKColor), new TypeConverterAttribute(typeof(SKColorTypeConverter))); TypeDescriptor.AddAttributes(typeof(SKRect), new TypeConverterAttribute(typeof(SKRectTypeConverter))); TypeDescriptor.AddAttributes(typeof(SKSize), new TypeConverterAttribute(typeof(SKSizeTypeConverter))); TypeDescriptor.AddAttributes(typeof(SKPoint), new TypeConverterAttribute(typeof(SKPointTypeConverter))); } }