2026-01-01 06:22:48 -05:00
|
|
|
using System;
|
2025-12-21 13:26:56 -05:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Maui.Animations;
|
|
|
|
|
using Microsoft.Maui.Dispatching;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Hosting;
|
|
|
|
|
|
|
|
|
|
public class LinuxMauiContext : IMauiContext
|
|
|
|
|
{
|
2026-01-01 06:22:48 -05:00
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
|
|
|
|
|
|
private readonly IMauiHandlersFactory _handlers;
|
|
|
|
|
|
|
|
|
|
private readonly LinuxApplication _linuxApp;
|
|
|
|
|
|
|
|
|
|
private IAnimationManager? _animationManager;
|
|
|
|
|
|
|
|
|
|
private IDispatcher? _dispatcher;
|
|
|
|
|
|
|
|
|
|
public IServiceProvider Services => _services;
|
|
|
|
|
|
|
|
|
|
public IMauiHandlersFactory Handlers => _handlers;
|
|
|
|
|
|
|
|
|
|
public LinuxApplication LinuxApp => _linuxApp;
|
|
|
|
|
|
|
|
|
|
public IAnimationManager AnimationManager
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_animationManager == null)
|
|
|
|
|
{
|
|
|
|
|
_animationManager = (IAnimationManager?)(((object)_services.GetService<IAnimationManager>()) ?? ((object)new LinuxAnimationManager((ITicker)(object)new LinuxTicker())));
|
|
|
|
|
}
|
|
|
|
|
return _animationManager;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IDispatcher Dispatcher
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_dispatcher == null)
|
|
|
|
|
{
|
|
|
|
|
_dispatcher = (IDispatcher?)(((object)_services.GetService<IDispatcher>()) ?? ((object)new LinuxDispatcher()));
|
|
|
|
|
}
|
|
|
|
|
return _dispatcher;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LinuxMauiContext(IServiceProvider services, LinuxApplication linuxApp)
|
|
|
|
|
{
|
|
|
|
|
_services = services ?? throw new ArgumentNullException("services");
|
|
|
|
|
_linuxApp = linuxApp ?? throw new ArgumentNullException("linuxApp");
|
|
|
|
|
_handlers = services.GetRequiredService<IMauiHandlersFactory>();
|
|
|
|
|
}
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|