mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-03 11:03:39 +00:00
Refactor fetching Avalonia TopLevel
This commit is contained in:
@@ -8,14 +8,18 @@ internal static class AvaloniaExtensions
|
|||||||
{
|
{
|
||||||
extension(IApplicationLifetime lifetime)
|
extension(IApplicationLifetime lifetime)
|
||||||
{
|
{
|
||||||
public Window? TryGetMainWindow() =>
|
public Control? TryGetMainView() =>
|
||||||
lifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime
|
lifetime switch
|
||||||
? desktopLifetime.MainWindow
|
{
|
||||||
: null;
|
IClassicDesktopStyleApplicationLifetime desktopLifetime =>
|
||||||
|
desktopLifetime.MainWindow,
|
||||||
|
|
||||||
public TopLevel? TryGetTopLevel() =>
|
ISingleViewApplicationLifetime singleViewLifetime => singleViewLifetime.MainView,
|
||||||
lifetime.TryGetMainWindow()
|
|
||||||
?? (lifetime as ISingleViewApplicationLifetime)?.MainView?.Pipe(TopLevel.GetTopLevel);
|
_ => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
public TopLevel? TryGetTopLevel() => lifetime.TryGetMainView()?.Pipe(TopLevel.GetTopLevel);
|
||||||
|
|
||||||
public bool TryShutdown(int exitCode = 0)
|
public bool TryShutdown(int exitCode = 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user